Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

In the Self-Check 2.17 it keeps saying I haven't used a variable 4 times so I cannot get the answer correct. Help?

+2 votes
public class ComputePay {
    public static final double TAX_RATE = 0.20;
   
    public static final double HOURLY_SALARY = 8.75;
   
    public static void main(String[] args) {
        // Calculate pay at work based on hours worked each day
       
        System.out.println("My total hours worked:");
       
        int hours = 21;
       
        System.out.println(hours); // my first variable use

        System.out.println("My hourly salary:");
        
        System.out.println(HOURLY_SALARY); // second use
              
        System.out.println("My total pay:");
       
        System.out.println( hours * HOURLY_SALARY); //third and fourth use?

        System.out.println("My taxes owed:"); // 20% tax
        
        System.out.println(hours * HOURLY_SALARY * TAX_RATE); //fifth sixth and seventh use?!
    }
}
asked Sep 6 in CSC 211 (F17) by Caleb Westerman (579 points)
what worked for me was declaring all of the variables at the beginning after the main

2 Answers

+2 votes
The problem is asking for you to declare variables. Variables are declared with the <type> <name> equals <value>.
answered Sep 7 by Kathryn Clark (1,079 points)
0 votes
The problem is asking for you to declare variables.
answered Sep 12 by Ricardo Garcia (512 points)
...