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: | 304 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