Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Case Study 1: Compute Weekly Pay We illustrate the use of logical operators by writing a program to compute weekly pay. Request Write a

Javaimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Case Study 1: Compute Weekly Pay We illustrate the use of logical operators by writing a program to compute weekly pay. Request Write a program to compute the weekly pay of hourly employees. Analysis Employees are paid at a base rate for the first 40 hours they work each week. Hours over 40 are paid at an overtime rate equal to twice the base rate. An exception is made for part- time employees, who are always paid at the regular rate, no matter how many hours they work. The hourly rate is in the range $6.75 to $30.50 and hours worked in the range 1 to 60. We use a type attribute to distinguish between full-time (type 1) and part-time (type 2) employ ees. Figure 7-1 shows the user interface. We would also like the program to be robust -that is, to handle invalid inputs without crashing or producing meaningless results. The easiest and best way to achieve this end is to check data values as soon as they are entered and reject those that are invalid. The user is then given another opportunity to enter a correct value, as shown in Figure 7-2 FIGURE 7-1 Interface for the compute weekly pay program Enter employee data Name (or blank to quit): Susan Jones Type (1 or 2): 1 Hourly rate (between 6.75 and 30.50, inclusive): 10.50 Hours worked (between 1 and 60, inclusive): 50 The weekly pay for Susan Jones is $630.0 Enter employee data Name (or blank to quit): Bill Smith Type (1 or 2): 2 Hourly rate (between 6.75 and 30.50, inclusive): 15.00 Hours worked (between 1 and 60, inclusive): 60 The weekly pay for Bill Smith is $900.0 Enter employee data Name (or blank to quit): FIGURE 7-2 How the program responds to invalid inputs Enter employee data Name (or blank to quit): Patricia Nelsorn Type (1 or 2): 3 Type (1 or 2):0 Type (1 or 2): 1 Hourly rate (between 6.75 and 30.50, inclusive): 99.00 Hourly rate (between 6.75 and 30.50, inclusive): 3.75 Hourly rate (between 6.75 and 30.50, inclusive): 20.89 Hours worked (between 1 and 60, inclusive): 100 Hours worked (between 1 and 60, inclusive): 25 The weekly pay for Patricia Nelson is $522.25 Main.java Employee.java 1 File: Main.java * Author * Date: * Class/Period : AP CSA - Per. # *E-mail Address: * Description: * Case Study Case Study 7.2: Display the nth Fibonacci number * 1. Request employee name, type, pay rate, and hours. 4 6 8 10 2. Print employee name and pay. *3. Repeat until the name is blank. 12 13 import java.util.scanner; 14 // implement PayrollSystemApp here in the Main class public class Main Main.java Employee.java 1 File: Main.java *Author: Date: 4 * Class/Period : AP CSA - Per. # 5 -mail Address: 6 Description: 7Employee.java * 1. Instance variables: name, type, rate, hours 9*. Methods to get data validation rules set instance 1e variables if data are valid get name and pay 12 13 public class Employee ( 14

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions