Question
Use jGRASP to complete the following programs and understand what they do. / /*************************************************************************************** / / Wages.java / / Demonstrates the use of an if-else
Use jGRASP to complete the following programs and understand what they do. / /*************************************************************************************** / / Wages.java / / Demonstrates the use of an if-else statement. / / ************************************************************************************** import java.text.NumberFormat; import java.util.Scanner; public class Wages { / / ----------------------------------------------------------------------------------------------------- / / Reads the number of hours worked and calculates wages. / / ----------------------------------------------------------------------------------------------------- public static void main(String[] args) { final double RATE = 8.25; / / regular pay rate final int STANDARD = 40; / / standard hours in a work week double pay = 0.0; int hours; NumberFormat fmt = NumberFormat.getCurrencyInstance(); Scanner scan = new Scanner(System.in); System.out.print("Enter the number of hours worked: "); hours = scan.nextInt(); System.out.println (); / / Pay overtime at "time and a half" if (hours > STANDARD) pay = STANDARD * RATE + (hours - STANDARD) * (RATE * 1.5); else pay = hours * RATE; System.out.println("Gross earnings: " + fmt.format(pay)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started