D
Deleted member 29591
Guest
I'm in a beginners programming class and I have a program that is due monday. It's supposed to calculate a sales tax of %6.25 if you live in utah or idaho and just tell you the price if you live in another state. I'll post my code so far, hopefully someone can tell me what i'm doing wrong. Right now it if i put in a value, like 8 dollars it tells me
Enter the price of the item 0.0 8.00
What state do you live in?u
Your tax is $0.5
Your total is $8.00
and if i do a different state, say oregon, it works perfectly.
Enter the price of the item 0.0 8.00
What state do you live in?
Your tax is $0.0
Your total is $8.0
Anyway, here's the code
public class prog2
{
public static void main(String[] args)
{
double tax = 0.0;
double total = 0.0;
double price = 0.0;
char state = 'u';
price = Console.readDouble("Enter the price of the item " + price + " ");
state = Console.readChar("What state do you live in?");
if (state == 'u' || state == 'U' || state == 'I' || state == 'i') {
tax = 0.0625;
tax = (price * tax);
}
System.out.println("Your tax is $" + tax);
System.out.println("Your total is $" + price);
}
}
by the way, Console.class is a program they give you so you can recieve user input. It's supposedly really hard to recieve user input in java.
Enter the price of the item 0.0 8.00
What state do you live in?u
Your tax is $0.5
Your total is $8.00
and if i do a different state, say oregon, it works perfectly.
Enter the price of the item 0.0 8.00
What state do you live in?
Your tax is $0.0
Your total is $8.0
Anyway, here's the code
public class prog2
{
public static void main(String[] args)
{
double tax = 0.0;
double total = 0.0;
double price = 0.0;
char state = 'u';
price = Console.readDouble("Enter the price of the item " + price + " ");
state = Console.readChar("What state do you live in?");
if (state == 'u' || state == 'U' || state == 'I' || state == 'i') {
tax = 0.0625;
tax = (price * tax);
}
System.out.println("Your tax is $" + tax);
System.out.println("Your total is $" + price);
}
}
by the way, Console.class is a program they give you so you can recieve user input. It's supposedly really hard to recieve user input in java.