Hello, I started writing java. I have the first and second steps done (well, i cannot get the program to loop if the user says yes, and I'm also having problems with the if/else statements)
Here is my code:
public class bh {
public static void main (String agrs[])
{
double salary, total, tax, taxes, money;
int hours;
char answer;
System.out.print("Enter salary per hour: ");
salary = DummiesIO.getDouble();
System.out.print("Enter tax as a percent (eg. .30): ");
tax = DummiesIO.getDouble();
if (tax >= .0 && tax <= 1.0)
System.out.print("Enter number hours worked: ");
else
System.out.print("Invalid Entry. Please enter a number between .0 and .90 : ");
tax = DummiesIO.getDouble();
System.out.print("Enter tax as a percent (eg. .30): ");
tax = DummiesIO.getDouble();
{
if (tax >= .0 && tax <= 1.0)
{
total = (salary * tax);
taxes = (salary - total);
money = (taxes * hours);
System.out.print("You have made: $ ");
System.out.print(money);
}
else
System.out.print("Invalid Entry. Please enter a number between .0 and .90 : ");
tax = DummiesIO.getDouble();
}
/*System.out.print("Do you want to calculate more hours? (Yes / No): ");
reply = DummiesIO.getChar();
if (reply = "Yes")
{
System.out.print("Enter salary per hour: ");
salary = DummiesIO.getDouble();
System.out.print("Enter tax as a percent (eg. .30): ");
tax = DummiesIO.getDouble();
System.out.print("Enter number hours worked: ");
hours = DummiesIO.getInt();
System.out.print("Enter tax as a percent (eg. .30): ");
tax = DummiesIO.getDouble();
total = (salary * tax);
taxes = (salary - total);
money = (taxes * hours);
System.out.print("You made : $");
System.out.println(money);
}
else
{
System.out.print("Thank You. Bye ");
}*/
}
}
The error message i get is with this line :
and the error message states :
nub:~/Desktop/JavaStuff Josh$ javac bh.java
bh.java:42: variable hours might not have been initialized
money = (taxes * hours);
^
1 error
Please help. Thanks