Quote (lilwillis121 @ Sep 5 2013 11:15am)
we were assigned to use jgrasp
Just going through the process and im getting
InterestCh2.java:36: error: variable Hours might not have been initialized
but Hour is dependent on imput. help?
Code
import java.util.*;
public class InterestCh2
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
final double PAY_RATE = 15.50;
final double TAXES = .86;
final double CLOTHES = .10;
final double SCHOOL_SUPPLIES = .01;
final double REMAINDER_SAVINGS_BONDS = .25;
final double PARENTS_BONDS = .50;
int Hours;
final double MONEY = (Hours * PAY_RATE);
System.out.println("Enter number of hours worked");
Hours = console.nextInt();
System.out.println("Total Pay = " + Hours * PAY_RATE );
System.out.println("Money before taxes:" + Hours * PAY_RATE);
System.out.println("Money after taxes:" + MONEY * TAXES);
change
Code
int Hours;
to
Code
int Hours = 0;
or remove that line and change line
Code
Hours = console.nextInt();
to
Code
int Hours = console.nextInt();
Also, you should change the variable name to "hours" instead of "Hours". It's proper syntax to start variable names with a lowercase letter
Also, move
Code
final double MONEY = (Hours * PAY_RATE);
after you initialize Hours
This post was edited by labatymo on Sep 5 2013 09:47am