Write the program. Its urgent....
Answers
import java.util.*;
public class Scanner
{
public static void main(String args[])
{
Scanner in= new Scanner(System.in);
String name, month;
int n,u;
double p=0.0;
System.out.println("Enter the name of the consumer");
name= in.nextString();
System.out.println("Enter the name of the month");
month= in.nextString();
System.out.printl("Enter the number of the consumer");
n =in.nextInt();
System.out.println("Enter the amount of unit consumed by the consumer");
u=in.nextInt();
if(u<=100)
p=u*1.80;
if(u>100 && u<=300)
p= u*2.30;
if(u>300 && u<=500)
p= u*2.80;
if(u>500)
p=u*3.50;
System.out.println("Consumer's name:" +name);
System.out.println("Consumer's number:" +n);
System.out.println("Electricity bill for the month:" +month);
System.out.println("Units consumed:" +u);
System.out.println("The amounts to be paid:" +p);
}
}
Answer:
import java.util.*;
public class Scanner
{
public static void main(String args[])
{
Scanner in= new Scanner(System.in);
String name, month;
int n,u;
double p=0.0;
System.out.println("Enter the name of the consumer");
name= in.nextString();
System.out.println("Enter the name of the month");
month= in.nextString();
System.out.printl("Enter the number of the consumer");
n =in.nextInt();
System.out.println("Enter the amount of unit consumed by the consumer");
u=in.nextInt();
if(u<=100)
p=u*1.80;
if(u>100 && u<=300)
p= u*2.30;
if(u>300 && u<=500)
p= u*2.80;
if(u>500)
p=u*3.50;
System.out.println("Consumer's name:" +name);
System.out.println("Consumer's number:" +n);
System.out.println("Electricity bill for the month:" +month);
System.out.println("Units consumed:" +u);
System.out.println("The amounts to be paid:" +p);
}
}