> I need help with a Java Wage calculator problem. I am new to Java.?

I need help with a Java Wage calculator problem. I am new to Java.?

Posted at: 2014-12-18 
you are almost there...

import java.util.Scanner;

public class Program {

public static void main(String[] args) {

final double REGULAR_HOUR = 40f;

final double HOURLY_WAGE = 12.5f;

final double OVERTIME = 1.5f;



Scanner keyboard = new Scanner(System.in);

System.out.println("Enter regular hours worked? ");

double hour = keyboard.nextDouble();



double wage = 0f;

if (hour <= REGULAR_HOUR) {

wage = hour * HOURLY_WAGE;

} else {

wage = REGULAR_HOUR * HOURLY_WAGE;

wage += (hour - REGULAR_HOUR) * HOURLY_WAGE * OVERTIME;

}



System.out.format("The wage is %,.2f", wage);

System.exit(0);

}

}

You don't seem to be trying very hard.

System.out.println ("Enter regular hours worked: ");

double total = keyboard.nextDouble ();

Your prompt does not seem to match the variable (total)

In any case, once you have read total, you fail to use it.

Then you calculate EITHER weeklyPay or totalPay and fail to do anything with either of them.

You have a variable, overtime Hours, that you don't use in any way.

regularHours is a constant. There are no rules for the name, but constants are commonly in all caps:

REGULAR_HOURS

When you calculate totalPay you are using both regularHours AND a literal 40.

===============

Edit:

A = 3 + 4

C = B + 19

How much is C?

It should be obvious to you that you cannot calculate C because you do not know the value of B. You can see that A has been calculated, but it is useless.

You don't need to know Java to recognize this.

Your problem has nothing to do with Java. That is what you need to understand. It has nothing to do with Java -- except you are letting yourself think it is, that that wrong thinking is overwhelming you. It is preventing to from seeing what is obvious.

Or, did you get the code above from someone else? Is that why it doesn't make sense? Did someone give you nonsensical code?

Focus on these 2 lines:

System.out.println ("Enter regular hours worked: ");

double total = keyboard.nextDouble ();

What are they doing?

What are they *SUPPOSED* to be doing?

I am going to school for IT. Do not want to be a programmer, but have to take a few of these classes so I can get a degree. I am still new to Java and I am trying the best I can.

import java.util.Scanner;



public class RoyJa01WageCalc

{

public static void main(String [] args)

{



final double regularHours = 40;

final double hourlyWage = 12.50;

double overtimeHours;

double weeklyPay;

double totalPay;

int hours = 0;

Scanner keyboard = new Scanner(System.in);



System.out.println("Enter regular hours worked: ");



double total = keyboard.nextDouble ();



if

(hours<=40) weeklyPay = hourlyWage * regularHours;



else

totalPay= (hours - 40 * 1.5 * hourlyWage) + (hourlyWage*regularHours);

}

}