I am trying to get my output to match the output shown in the image. I think my variable values are getting crossed and giving me the incorrect output. also if you have any tips on how I can better organize my code I'd greatly appreciate it! Thank you! import java.util.Scanner; public class Program4 {      //*************************************************************** // // Method: main // // Description: The main method of the program // // Parameters: String array // // Returns: N/A // //**************************************************************      //start of main() method          public static void main(String[] args) {                            Scanner input = new Scanner(System.in);          //get employee info          System.out.print("Enter your ID number: ");     int employeeID = input.nextInt();          System.out.print("Enter you Payrate: ");     double hourlyPay = input.nextDouble();          System.out.print("Enter your hours worked: ");     double hoursWorked = input.nextDouble();          //Calculate Regular and overtime pay          double regularHoursPay;     double overTimeHoursPay = 0;          if (hoursWorked <= 40){         regularHoursPay = hoursWorked * hourlyPay;     }          else {         overTimeHoursPay = hoursWorked - 40;         regularHoursPay = overTimeHoursPay * (hourlyPay * 1.5);              }          //Calculate gross pay          double grossPay;     double overTimeHours = 0;          if(hoursWorked <= 40) {         grossPay = hoursWorked * hourlyPay;     }          else {      overTimeHours = hoursWorked - 40;         grossPay = hourlyPay * 40 + overTimeHours * hourlyPay * 1.5;         }          //Calculate deductions          double incomeTax = 0;     double parkingCharge = 35;     double totalDeduction = (incomeTax + parkingCharge);          if(grossPay > 750) {         incomeTax = grossPay * .1275 ;     }          //Calculate net pay          double netPay = grossPay - totalDeduction;          //Display employee results          System.out.println("Program 4 ");     System.out.printf("ID Number: %d%n", employeeID);     System.out.printf("Pay Rate: %.2f%n", hourlyPay);     System.out.printf("Regular Hours: %.2f%n", hoursWorked);     System.out.printf("Overtime Hours: %.2f%n", overTimeHours);     System.out.printf("Total Hours: %.2f%n", overTimeHours + hoursWorked);     System.out.printf("Regular Pay: %.2f%n", regularHoursPay);     System.out.printf("Overtime Pay: %.2f%n", overTimeHoursPay);     System.out.printf("Gross Pay: %.2f%n", grossPay);     System.out.printf("Tax: %.2f%n", incomeTax);     System.out.printf("Deductions: %.2f%n", totalDeduction);     System.out.printf("Net Pay: %.2f%n", netPay);          }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am trying to get my output to match the output shown in the image. I think my variable values are getting crossed and giving me the incorrect output. also if you have any tips on how I can better organize my code I'd greatly appreciate it! Thank you!

import java.util.Scanner;


public class Program4 {
    
//***************************************************************
//
// Method: main
//
// Description: The main method of the program
//
// Parameters: String array
//
// Returns: N/A
//
//**************************************************************
    
//start of main() method
    
    public static void main(String[] args) {
        
    
        
    Scanner input = new Scanner(System.in);
    
    //get employee info
    
    System.out.print("Enter your ID number: ");
    int employeeID = input.nextInt();
    
    System.out.print("Enter you Payrate: ");
    double hourlyPay = input.nextDouble();
    
    System.out.print("Enter your hours worked: ");
    double hoursWorked = input.nextDouble();
    
    //Calculate Regular and overtime pay
    
    double regularHoursPay;
    double overTimeHoursPay = 0;
    
    if (hoursWorked <= 40){
        regularHoursPay = hoursWorked * hourlyPay;
    }
    
    else {
        overTimeHoursPay = hoursWorked - 40;
        regularHoursPay = overTimeHoursPay * (hourlyPay * 1.5);
        
    }
    
    //Calculate gross pay
    
    double grossPay;
    double overTimeHours = 0;
    
    if(hoursWorked <= 40) {
        grossPay = hoursWorked * hourlyPay;
    }
    
    else {
     overTimeHours = hoursWorked - 40;
        grossPay = hourlyPay * 40 + overTimeHours * hourlyPay * 1.5;    
    }
    
    //Calculate deductions
    
    double incomeTax = 0;
    double parkingCharge = 35;
    double totalDeduction = (incomeTax + parkingCharge);
    
    if(grossPay > 750) {
        incomeTax = grossPay * .1275 ;
    }
    
    //Calculate net pay
    
    double netPay = grossPay - totalDeduction;
    
    //Display employee results
    
    System.out.println("Program 4 ");
    System.out.printf("ID Number: %d%n", employeeID);
    System.out.printf("Pay Rate: %.2f%n", hourlyPay);
    System.out.printf("Regular Hours: %.2f%n", hoursWorked);
    System.out.printf("Overtime Hours: %.2f%n", overTimeHours);
    System.out.printf("Total Hours: %.2f%n", overTimeHours + hoursWorked);
    System.out.printf("Regular Pay: %.2f%n", regularHoursPay);
    System.out.printf("Overtime Pay: %.2f%n", overTimeHoursPay);
    System.out.printf("Gross Pay: %.2f%n", grossPay);
    System.out.printf("Tax: %.2f%n", incomeTax);
    System.out.printf("Deductions: %.2f%n", totalDeduction);
    System.out.printf("Net Pay: %.2f%n", netPay);
    
    }

Name:
Instructor
Course: ITSE 2321 Object-Oriented Programming (Java)
Program: Four
This program computes an employee's gross, net, and overtime pay.
Enter your ID Number: 1001
Enter your pay rate: 12.50
Enter your hours worked: 36
Program 4
ID Number:
Pay Rate:
Regular Hours:
Overtime Hours:
Total Hours:
Regular Pay:
Overtime Pay:
Gross Pay:
Tax:
Deductions:
Net Pay:
1001
12.50
36.00
0.00
36.00
450.00
0.00
450.00
0.00
35.00
415.00
Transcribed Image Text:Name: Instructor Course: ITSE 2321 Object-Oriented Programming (Java) Program: Four This program computes an employee's gross, net, and overtime pay. Enter your ID Number: 1001 Enter your pay rate: 12.50 Enter your hours worked: 36 Program 4 ID Number: Pay Rate: Regular Hours: Overtime Hours: Total Hours: Regular Pay: Overtime Pay: Gross Pay: Tax: Deductions: Net Pay: 1001 12.50 36.00 0.00 36.00 450.00 0.00 450.00 0.00 35.00 415.00
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education