Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Declare five ( 5 ) one-dimensional arrays t hat are named stuCode, stuHours, hou

ID: 3838197 • Letter: D

Question

Declare five (5) one-dimensional arrays that are named stuCode, stuHours, hourlyPay, grossPay, & netPay to store values for the student detail fields for each record.

stuCode should be an int array

stuHours should be an int array

hourlyPay should be a float or double array

grossPay should be a float or double array

netPay should be a float or double array

You may create additional arrays if you find it useful in solving the problem.

The values for any/all of the original Input fields, as defined by the test data, can either be initialized within the Java source code and/or be input from the keyboard to store the Test Data. Meaning if all the test data is initialized within the Java source code there is no input to enter.

DOE Monthly Sales Transactions

Date November 4, 2016

Pay Deductions (Rate) 13%

100

20

11.5

200

28

11.5

300

32

11.5

400

32

11.5

500

30

12.5

600

25

12.5

700

32

12.5

0

The values for the grossPay and netPay arrays must be calculated by the program during the execution of the program.

You must use at least one for loop to process the arrays.

If there is input from the keyboard then no report output should display until "after all input is complete".

The per item detail portion of the report should display the data stored in the:

stuCode

stuHours

hourlyPay

grossPay

netPay

arrays to the screen in a table format with neatly aligned columns and appropriate column headings as seen in the example below. Each array should represent a column in the output.
Note: Use of the space or tab character within the output string helps to make columns.

The summary portion of the report should display the data values along with appropriate titles/headings laid out neatly in a horizontal or vertical order.

All decimal output must have two decimal places with commas and trailing zeroes displayed when needed.

All monetary values must display with a leading dollar sign ($).

All monetary values must display with 2 decimal places with commas (when needed) and trailing zeroes.

This includes all floating point variables whether or not the variables are stored in an array.

Have a minimum of five methods in the second (non-driver) class. The appMain methods does count towards the minimum.

/*

Source Name:             Project3Driver.java

Data Written:              5/11/2017

Written By:

*/

import java. io*;

public class Projt3Driver

{

            public static void main(String args[] throws IOException

            {

                        Project3 app;

                        app = new Project3();

                        app.appMain ();

            }

}

class Project3

{

            // Data (Field) Declaration, so declare all your variables HERE

            BufferedReader stdin;

           

            int stuCode, hours;

            float hourlyPay, grossPay, netPay;

            int highHours, hiHoursStudent;

            String date;

            float deductionRate;

            int totstus, totOTHours;

            float totNetPay, overTimePay;

            float avgGrossPay, totGrossPay;

           

            void appMain() throws IOException

            {

                        outputHeader();

                        initReport();

                        getWeekInfo();

                        while (stuCode !=0)

                        {

                                    procStudent();

                        }

                        calculateAvg();

                        displaySummary();

            }

            void outputHeader()

            {

                        //Output report header.

                        System.out.println(“Solution for Proj #3”);

                        System.out.println(“GEST Weekly Payroll Report”)

                        System.out.println(“Name here”);

            }

            void initReport()

            {

                        // create input input object to connect to the keyboard

                        stdin = new BufferReader (new InputStreamReader(System.in));

           

                        totNetPay = 0;

                        highHours = 0;

                        totStus = 0;

                        stuCode = -1;               // initialize to any non-flag value

            }

            void getWeekInfo() throws IOExeption

            {

                        //output report header

                        System.out.print(“Please enter the date: “);

                        date = stdin. readLine();

                        System.out.Print(“Please enter the Pay Deductions Rate; “);

                        deductionRate = Float.parseFloat(stdin.redLine());

            }

            void procStudent() throws IOException

            }

                        getStuCode();

                        if (stuCode !=0)

                        {

                                    getStuDetails();

                                    if   (stuCode !=0)

                                    {

                                                getStuDetails();

                                                calcDetailsAndTotals();

                                                updateHighs();

                                                displayDetails();

                                    }

                        }

            void getStuCode() throws IOException

            {

                        System.out.println(“ =========== Student Input ===========”);

                        System.out.print(Please enter the Student ID Code; “);

                        stuCode = Integer.parseInt(stdin.redLine());

            }

            void getStuDetails() throws IOException

            {

                        System.out.print(“Please enter the number of hours worked; “);

                        Hours = Integer.parseInt(stdin.readLine());

                        System.out.print (“Please enter the hourly pay rate; “)

                        HourlyPay = Float.parseFloat(stdin.redLine();

            }

            void displayDetails()

            {

                        System.out.println(“ ”);

                        System.out.println(“Student Details: “)

                        System.out.println(“=======================================”);

                        System.out.println(“Student Code: Code: ” + stuCode);

                        System.out.println(“Hours Worked: ” + hours);

                        System.out.println(“Hourly Pay: ” + hourlyPay);

                        System.out.println(“Gross Pay: ” + grossPay):

                        System.out.println(“Net Pay: ” + netPay);

                        System.out.println(“=======================================”);

            }

            void calcDetailsAndTotals()

            {

                        //calculate for detail output

                        grossPay = hours * hourlyPay;

                       

                        if (hours > 25)

                        {

                                    grossPay = grossPay + ((hours - 25) * ((float)0.5 * hourlyPay));

                                    totOTHours = totOTHours + (hours – 25);

                        }

                        netPay = grossPay – (grossPay * deductionRate);

                        //calculate for report summary

                        totNetPay = totNetPay + netPay;

                        totGrossPay = totGrossPay + grossPay;

                       

                        totStus = totStus +1;

            )

            void updateHights()

            {

                        if (highHours < hours)

                        {

                                    highHours = hours:

                                    hiHoursStudent = stuCode;

                        }

            }

            void calculateAvg()

            {

                        avgGrossPay = totGrossPay / totStus;

            }

            void displaySummary()

            {

                        System.out.println(“ ”);

                        System.out.println(“*GEST WEEKLY PAYROLL REPORT SUMMARY*”)

                        System.out.println(“=======================================”);

                        System.out.println(“Date: ” + date);

                        System.out.println(“Deductions Rate: ” + deductionRate);

                        System.out.println(“=======================================”);

                        System.out.println(“Total Net Pay: ” + totNetPay);

                        System.out.println(“Total OT Hours: ” = totOTHours);

                        System.out.println(“Average Gross Pay: ” + avgGrossPay);

                        System.out.println(“High Hours Worked: ” + highHours);

                        System.out.println(“High Hours Student: ” + hiHoursStudent);

                        System.out.println(“=======================================”);

            }

}

Here is an example of what the program execution could resemble.


$ script proj5log
Script started, file is proj5log

$ javac Projk 5Driver.java

$ java Project5Driver


===========================================================================
Author: Name here
Project #5: A bigger and better GEST program.


===========================================================================
===========================================================================
GEST: Weekly Report
Date: November 4, 2016
Deductions Rate: 0.13
===========================================================================
STUDENT SUMMARY

Stu           Stu         Hourly        Gross          Net
Code        Hours   Pay             Pay               Pay
----          -----       ------           ---------      ---------
100           20          $11.50         $230.00         $200.10
200         28          $11.50         $339.25         $295.15
300         32          $11.50         $408.25         $355.18
400         32        $11.50         $408.25         $355.18
500         30        $12.50         $406.25         $353.44
600         25        $12.50         $312.50         $271.88
700           32        $12.50         $443.75         $386.06

-------------------------------------------
OVERALL SUMMARY
-------------------------------------------
Date:                              November 4, 2016
Deductions Rate:          0.13
Total Net Pay:              $2,216.98
Total OT Hours:            29
Average Gross Pay:     $364.04
High Hours Worked:       32

High Hour Stus:
---------------
300
400
700
===========================================================================
===========================================================================

DOE Monthly Sales Transactions

Date November 4, 2016

Pay Deductions (Rate) 13%

Student Code Hours Worked Hourly Pay

100

20

11.5

200

28

11.5

300

32

11.5

400

32

11.5

500

30

12.5

600

25

12.5

700

32

12.5

0

Explanation / Answer

Find the code below.


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Projt3Driver {
   public static void main(String args[]) throws IOException {
       Project3 app;
       app = new Project3();
       app.appMain();
   }
}

class Project3 {
   // Data (Field) Declaration, so declare all your variables HERE
   BufferedReader stdin;
   int[] stuCode;
   int[] stuHours;
   double[] hourlyPay;
   double[] grossPay;
   double[] netPay;
   int highHours, hiHoursStudent;
   String date;
   float deductionRate;
   int totstus, totOTHours;
   double totNetPay;
   float overTimePay;
   double avgGrossPay;
   double totGrossPay;
   int code;
   int count = 0;

   void appMain() throws IOException {
       outputHeader();
       initReport();
       getWeekInfo();
       while (code != 0) {
           procStudent();
       }
       calculateAvg();
       displaySummary();
   }

   void outputHeader() {
       // Output report header.
       System.out.println("=================================================");
       System.out.println("Author : Name here");
       System.out.println("Project #5: A bigger and better GEST program");
       System.out.println("=================================================");
       System.out.println("GEST: Weekly Report");
   }

   void initReport() {
       // create input object to connect to the keyboard
       stdin = new BufferedReader(new InputStreamReader(System.in));
       totNetPay = 0;
       highHours = 0;
       totstus = 0;
       code = -1; // initialize to any non-flag value
   }

   void getWeekInfo() throws IOException {
       // output report header
       System.out.print("Please enter the date: ");
       date = stdin.readLine();
       System.out.print("Please enter the Pay Deductions Rate: ");
       deductionRate = Float.parseFloat(stdin.readLine());
   }

   void procStudent() throws IOException {

       getStuCode();
       if (code != 0) {
           createArray();
           getStuDetails();
           calcDetailsAndTotals();
           updateHights();
           displayDetails();
       }
   }
   void createArray(){
       stuCode = new int[count];
       stuHours = new int[count];
       hourlyPay = new double[count];
       grossPay = new double[count];
       netPay = new double[count];
   }

   void getStuCode() throws IOException {
       System.out.println(" =========== Student Input ===========");
       System.out.print("Please enter the Student ID Code:");
       code = Integer.parseInt(stdin.readLine());
       count++;
   }

   void getStuDetails() throws IOException {
       System.out.print("Please enter the number of hours worked: ");
       for(int i =0; i<stuHours.length; i++){
           stuHours[i] = Integer.parseInt(stdin.readLine());
       }
       System.out.print("Please enter the hourly pay rate: ");
       for(int i =0; i<stuHours.length; i++){
           hourlyPay[i] = Float.parseFloat(stdin.readLine());
       }
   }

   void calcDetailsAndTotals() {
       // calculate for detail output
       for(int i =0; i<count; i++){
           grossPay[i] = stuHours[i] * hourlyPay[i];

       if (stuHours[i] > 25) {
           grossPay[i] = grossPay[i] + ((stuHours[i] - 25) * ((float) 0.5 * hourlyPay[i]));
           totOTHours = totOTHours + (stuHours[i] - 25);
       }
       netPay[i] = grossPay[i] - (grossPay[i] * deductionRate/100);
       // calculate for report summary
       totNetPay = totNetPay + netPay[i];
       totGrossPay = totGrossPay + grossPay[i];
       totstus = totstus + 1;
       }
      
   }
  
   void displayDetails() {
       System.out.println(" ");
       System.out.println("Student Details: ");
       System.out.println("=======================================");
       for (int i = 0; i < stuCode.length; i++) {
           System.out.println("Student Code: " + stuCode[i]);
           System.out.println("Hours Worked: " + stuHours[i]);
           System.out.println("Hourly Pay : " + hourlyPay[i]);
           System.out.println("Gross Pay : " + grossPay[i]);
           System.out.println("Net Pay : " + netPay[i]);
           System.out.println("=======================================");
       }
  
   }

   void updateHights() {
       for(int i =0;i<count;i++){
           if (highHours < stuHours[i]) {
               highHours = stuHours[i];
               hiHoursStudent = stuCode[i];
           }
       }
      
  
   }

   void calculateAvg() {
       avgGrossPay = totGrossPay / totstus;
   }

   void displaySummary() {
       System.out.println(" ");
       System.out.println("*GEST WEEKLY PAYROLL REPORT SUMMARY*");
       System.out.println("=======================================");
       System.out.println("Date: " + date);
       System.out.println("Deductions Rate: " + deductionRate);
       System.out.println("=======================================");
       System.out.println("Total Net Pay: " + totNetPay);
       System.out.println("Total OT Hours: " + totOTHours);
       System.out.println("Average Gross Pay: " + avgGrossPay);
       System.out.println("High Hours Worked: " + highHours);
       System.out.println("High Hours Student: " + hiHoursStudent);
       System.out.println("=======================================");
   }
}

output:

=================================================
Author : Name here
Project #5: A bigger and better GEST program
=================================================
GEST: Weekly Report
Please enter the date: 01-01-2010
Please enter the Pay Deductions Rate: 4


=========== Student Input ===========
Please enter the Student ID Code:5
Please enter the number of hours worked: 7
Please enter the hourly pay rate: 24


Student Details:
=======================================
Student Code:    0
Hours Worked:    7
Hourly Pay :    24.0
Gross Pay :    168.0
Net Pay :    161.28
=======================================


=========== Student Input ===========
Please enter the Student ID Code:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote