The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Java 1
I am having issues with declaring the variables and constatnts in the code below. Its not a difficult program, but Im having issues with the math. Any help would be great.
I have the output formated as it needs to be, but I know I have the math messed up.
____________________-
import java.util.Scanner;
public class Wages
{
static Scanner keyboard = new Scanner (System.in);
public static void main(String[]args)
{
double rate = 12.50;
double hoursWorked = 0;
System.out.println("Enter the number of hours the employee worked");
hoursWorked = keyboard.nextDouble();
System.out.println();
double regularHours =0;
double overtimeHours = hoursWorked - regularHours;
double regularWages = regularHours * rate;
double overtimeWages = regularWages + (overtimeHours *rate*1.5);
double totalPay = regularWages + overtimeWages;
if (hoursWorked > 40.0)
totalPay = regularHours * rate + 1.5 * rate *(hoursWorked - regularHours);
else
totalPay = rate * hoursWorked;
System.out.println("****Wage Calculation****");
System.out.println("Number of hours worked: " + hoursWorked);
System.out.println("Number of regular hours worked:" + regularHours);
System.out.println("Amount of regular pay: " + regularWages);
System.out.println("Amount of overtime pay: " + overtimeWages);
System.out.println("Total Pay: $" + totalPay);
System.out.println();
}
}
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly