the program is supposed to calculate home or commercial gas usage and then print the type of customer,presen t reading,previou s reading,cubic used and cost for the month..the user inputs values btw 0-9999 and to determine number of cubic used subtract the previous from present.if present is less then previous subtract previous reading form 9999
add the current reading to that difference ot get cubic used
my trouble is the calculation i think if nothing else....
add the current reading to that difference ot get cubic used
my trouble is the calculation i think if nothing else....
import java.util.Scann er;
public class NameGasUtilityC ompany
{
public static void main(String [] args)
{
char choice;
int value,present,p revious,cubic;
char home,commercial ,name,usage;
double cost;
Scanner keyboard= new Scanner(System. in);
System.out.prin tln("Welcome to Name Gas");
name=keyboard.c harAt(0);
System.out.prin tln("What type of customer are you? 'H' or 'h'(home)|| 'C' or 'c' (commercial)");
choice=keyboard .charAt(0);
System.out.prin tln("Enter only cubic value in the range 0-9999");
value=keyboard. nextInt();
(usage = previous-present);
if(present < previous)
{ usage = (previous - 9999)* present;
(usage=present + usage);
else
usage = previous-present;
}
if (choice == 'H' || choice == 'h')
{
// use this formula constant
{if (cubic == 70)
cost = 5.00;
else if (cubic <= 100)
cost = cubic * .05;
else if (cubic <= 400)
cost = cubic * .025;
else
cost = cubic * .015;
}
if (choice == 'C' || choice == 'c')
{
//use this formula or constant
{if (cubic == 200)
cost = 30.00;
else if (cubic <=500)
cost = cubic * .04;
else if (cubic > 700)
cost = cubic * .03;
}
System.out.prin tln("Present meter reading" + present);
System.out.prin tln("Previous meter reading" + previous);
System.out.prin tln("Enter how many cubic used :" + usage);
System.out.prin tln("Cost this month $: " + cost);
}
}
}
}
public class NameGasUtilityC ompany
{
public static void main(String [] args)
{
char choice;
int value,present,p revious,cubic;
char home,commercial ,name,usage;
double cost;
Scanner keyboard= new Scanner(System. in);
System.out.prin tln("Welcome to Name Gas");
name=keyboard.c harAt(0);
System.out.prin tln("What type of customer are you? 'H' or 'h'(home)|| 'C' or 'c' (commercial)");
choice=keyboard .charAt(0);
System.out.prin tln("Enter only cubic value in the range 0-9999");
value=keyboard. nextInt();
(usage = previous-present);
if(present < previous)
{ usage = (previous - 9999)* present;
(usage=present + usage);
else
usage = previous-present;
}
if (choice == 'H' || choice == 'h')
{
// use this formula constant
{if (cubic == 70)
cost = 5.00;
else if (cubic <= 100)
cost = cubic * .05;
else if (cubic <= 400)
cost = cubic * .025;
else
cost = cubic * .015;
}
if (choice == 'C' || choice == 'c')
{
//use this formula or constant
{if (cubic == 200)
cost = 30.00;
else if (cubic <=500)
cost = cubic * .04;
else if (cubic > 700)
cost = cubic * .03;
}
System.out.prin tln("Present meter reading" + present);
System.out.prin tln("Previous meter reading" + previous);
System.out.prin tln("Enter how many cubic used :" + usage);
System.out.prin tln("Cost this month $: " + cost);
}
}
}
}
Comment