Question
Problem 2: Sophisticated Salary Calculation Write a Java class called Problem2.java whose main function does the exact same thing as problem 1, except that the
Problem 2: Sophisticated Salary Calculation Write a Java class called Problem2.java whose main function does the exact same thing as problem 1, except that the input and output formats are different. The detailed information is given as follows. Input The first line is the same as in Problem1 The second line , , and are still given in a single line for each employee, but in arbitrary or- der. To avoid ambiguity, the name of each variable is given, e.g., = 10. See below for an exam- ple. Also, the output is given in three lines: the middle line starts with the salary, a space, and then the word Dollars. The first and the last line are filled with *symbol; the number of stars is equal to the number of characters in the second line Processing Your program should perform the same task as in Problem 1 with the following modifications: Your program must handle the input data of employees in an arbitrary order, rather than in order as , , and in Problem 1 You will need a class StringBuilder to construct a blank string builder with a capacity of 16 char- acters o The way to use it is: StringBuilder str = new StringBuilder() o You can use the method str.append(s) appends the mentioned String str with the existing String s or other types like boolean, char, int, double, float, etc. Your program should include a method called digits which calculates the number of digits in the salary in order to match the number of stars in the output Output The output format is shown in the following example. There are three lines: (1) The first line is with stars (*); (2) The second line is the value of total salary plus one space plus the word Dollars; (3) The third line is also with stars. One thing needs to be noted is that the number of stars of the first line and the third line is equal to the number of characters in the second line. Please input the number of employees: 2 Please input data of employees: T=45 d=10 t=40 D=20 t=35 D=20 T=5 d=15 *********** 575 Dollars *********** problem 1 ex Suppose Willys Wing World restaurant would like to develop a salary calculation application. You are going to help them design the basic logic. The main function is to calculate an employees salary in total based on the input data. For example, Alices normal working time is hours per week. Each week, she receives dollars for each hour of normal work; but if she works beyond hours, then she would re- ceive dollars for each extra hour beyond hours. The same thing happened to every employee, and the output will be the salary for all employees. Write the body of the program called Problem1.java whose main function computes how much the company needs to pay for all the employees in a week. Assume , , , and are all non-negative inte- gers. The input to the program is two lines: (1) the number of employees and (2) , , and , respec- tively (the second line is separated by a space). Detailed information is given as follows. Input The input has two parts The number of employees, and it is an integer number Working hour and payment data of each employee The working hour and payment data contain the following information Normal working hour Wages per hour of normal work Extra wages per hour of extra work Actual working hour The console will print Please input the number of employees:. After inputting the integer number, the console will print Please input the data of employees:. Then the data of employees should be given in the order of , , and . See example below. Processing Your program should be able to calculate the total salary the company needs to pay in a week. Employees have their own normal working hour, and regular wage. However, if their working hours exceed the nor- mal working hour, extra wage will be paid to the employees.
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