Question

Objectives – to practice these new concepts: decision-making with if, if-else, if-else-if-… switch data validation for...

Objectives – to practice these new concepts:

  • decision-making with if, if-else, if-else-if-… switch

  • data validation for user input using a while (or while/do) loop

  • nicely formatted output report with printf and format strings

  • multiple input data sets using a while (or while/do) loop

  • named constants

PROJECT OVERVIEW

This project provides a detailed payroll report for the sales staff at TheLaptopShop. The company has 3 tiers of salespeople: low, middle, high (designated by L, M, H) – based on their past sales record. Each month they might get promoted to the next higher tier (or, if at the highest level already, receive a super bonus instead). The store sells 3 different laptop models: basic for $450.90, mid-range for $850.50 and high-end for $1350.95

A person’s pay includes 4 components:

  1. base salary

  2. commission - based on the number and types of laptops he/she sold that month:

$50 for each basic laptop, $100 for each mid-range laptop, $150 for each high-end laptop

  1. bonus - based on categories for his/her total sales that month (see below)

  2. super bonus – based on very high sales, if they’re already in the highest tier (see below)

Bonus is based on a person’s total sales amount and is calculated as follows:

Total sales categories Bonus amount

Up to $2,500 0% of total

$2,500.01 - $5,500 1% of total

$5,500.01 - $10,500 $75 + 2% of (total minus $5,500)

$10,500.01 - $13,500 $125 + 3% of (total minus $10,500)

Above $13,500 $375

Tier Promotion & Super Bonus:

If a salesperson earns a commission which is 75% or more of their base salary,

then they’re EITHER:

  1. promoted to the next higher tier (L  M or M  H)

  2. OR, if they’re ALREADY in the highest tier (H), the person earns a SUPER_BONUS instead

(a named constant currently set to $1000) which is added to their monthly pay.

STAGES of the PROGRAM DEVELOPMENT

0) program hardcodes the input data for ONE person, does the appropriate calculations and produces the output

payroll report for that person (see below for exact format)

1) AFTER STAGE 0 WORKS CORRECTLY

program gathers input data for one person from the user instead of using hardcoded data

2) AFTER STAGE 1 WORKS CORRECTLY

add data validation (see rules below) for the input gathering

3) AFTER STAGE 2 WORKS CORRECTLY

add looping so that the program can handle as many salespeople as the user provides.

(After handling one person, the program asks whether the user wants to enter data for another person,

then proceeds accordingly).

STAGE 3 VERSION OF THE PROGRAM IS THE ONE THAT YOU SHOULD SUBMIT TO GET THE FULL 100 POINTS.

INPUT (for 1 person)

Use dialog boxes with appropriate prompts to get the following 6 pieces of information from the user:

name, base salary, tier (L for low, M for middle, H for high),

number of basic laptops sold, number of mid-range laptops sold, number of high-end laptops sold

INPUT VALIDATION (added in stage 2)

  • Tier values must be one of: L, M, H (or l, m, h)

    • If it’s invalid, use the default, L, and tell the user what happened.

  • Base salary must be a positive number (integer or real number) that’s <= MAX_VALID_SALARY (a named constant set to $10,000 for now).

    • If it’s invalid, keep asking the user for a valid salary amount until they enter something correct.

  • Number of basic, mid-range and high-end laptops must each be a positive integer that is <= MAX_VALID_UNITS (a named constant set to 50 for now).

    • If it’s invalid, keep asking the user for a valid number of units until they enter something correct.

    • Each of the 3 types of laptops will have its own validation loop.

INPUT - MULTIPLE SALESPEOPLE (added in stage 3)

After printing the report for a single person, ask the user if they wish to enter another salesperson (YES or NO).

If they say YES (or Yes or yes or YEs or yeS or …) or Y (or y), then go around the big loop again.

(Use the String method toUpperCase() to reduce the number of cases to just YES and Y)

Any other response (like NO or nope or naw or whatever or who cares or …) will be assumed to be a NO.

PROCESSING (for 1 person)

Compute their monthly pay (base salary + commission + bonus + perhaps the SUPER_BONUS too.

Determine if they moved up a tier or not.

OUTPUT to the CONSOLE (a sample for 1 person)

[NOTE: the data below aren’t necessarily correct – I’m just showing you the FORMAT to use]

Salesperson: MARIA GONZALES

Starting Tier: High

New Tier: High

Laptops Sold: 9 basic, 15 mid-range, 12 high-end

Base Salary: $ 800.20

Commission: $ 1,200.00

Bonus: $ 152.28

Super Bonus: $ 1,000.00

-----------

Monthly Pay: $ 3,152.28

Congrats, you got the SUPER BONUS since you were already at the High tier

-------------------------------------------------------

[alternative message If they got promoted (though no super bonus)]

Congrads, you got promoted to the Middle tier

[alternative message If they didn’t sell >= 75% of their base salary]

Sorry, you didn’t get promoted to the next tier this month

OTHER PROGRAMMING REQUIREMENTS

  • follow JavaNamingConventions (shown on course website, 2nd lecture) for variables, constants, project name

  • use printf’s, mainly, for the output report

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • Program:

//Package for keyboard read
import java.util.Scanner;

public class PayrollReport {
//Constant variables
public static final double MAX_VALID_SALARY=10000;
public static final int MAX_VALID_UNITS =50;
public static final double SUPER_BONUS =1000;

public static void main(String[] args) {
  
//Variables for inputs
char repeat_choice,tier;
String sales_person_name="";
double basic_pay=0.0;
int basic_laptop_count=0,mid_range_laptop_count=0, high_end_laptop_count=0;
//Scanner object for input read
Scanner sc=new Scanner(System.in);
//Loop for user to enter details of sales person to generate report
do {
//User input about sales person
System.out.print("Ente sales person name: ");
sales_person_name=sc.nextLine();
System.out.println("Enter basic pay rate: ");
basic_pay=sc.nextDouble();
while(basic_pay<MAX_VALID_SALARY) {
System.out.println("Minimum basic pay is $10000,Please enter a value >= this value!!!");
System.out.println("Enter basic pay rate: ");
basic_pay=sc.nextDouble();
}
System.out.print("Enter the tier employee working(L-Low,M-Middle and H-High): ");
tier=sc.next().charAt(0);
tier=Character.toUpperCase(tier);
  
while(tier!='L'&&tier!='M'&&tier!='H'){
System.out.println("You entered tier is wrong!!!\nPlease enter L,M or H");
System.out.print("Enter the tier employee working(L-Low,M-Middle and H-High): ");
tier=sc.next().charAt(0);
tier=Character.toUpperCase(tier);
}
System.out.print("Enter the number of basic laptop sold: ");
basic_laptop_count=sc.nextInt();
while(basic_laptop_count<0&&basic_laptop_count<MAX_VALID_UNITS) {
System.out.println("Count should not be negative or not less than 50!!!");
System.out.print("Enter the number of basic laptop sold: ");
basic_laptop_count=sc.nextInt();
}
System.out.print("Enter the number of mid-range laptop sold: ");
mid_range_laptop_count=sc.nextInt();
while(mid_range_laptop_count<0&&mid_range_laptop_count<MAX_VALID_UNITS) {
System.out.println("Count should not be negative or not less than 50!!!");
System.out.print("Enter the number of mid-range laptop sold: ");
mid_range_laptop_count=sc.nextInt();
}
System.out.print("Enter the number of high-end laptop sold: ");
high_end_laptop_count=sc.nextInt();
while(high_end_laptop_count<0&&high_end_laptop_count<MAX_VALID_UNITS) {
System.out.println("Count should not be negative or not less than 50!!!");
System.out.print("Enter th

--------------------------------------------------------------------------END----------------------------------------------------------------------------------

Add a comment
Know the answer?
Add Answer to:
Objectives – to practice these new concepts: decision-making with if, if-else, if-else-if-… switch data validation for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping...

    Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping constructs (do and while loops) .Boolean expressions, bool and char types. 1. Develop a program that calculates charges for an Internet provider. The cost is determined by the amount of data used and the consumer plan. Package B (basic) is the most affordable if you plan on using < 20GB (20,000MB), however, if you consume more than 20GB (20,000MB) you are charged for each...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named...

    This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named Budgeter.java. To use a Scanner for console input, you must import java.util.*; in your code. This program prompts a person for income and expense amounts, then calculates their net monthly income. Below are two example logs of execution from the program. This program’s behavior is dependent on the user input (user input is bold and underlined below to make it stand out and differentiate...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • 4. Perform a SWOT analysis for Fitbit. Based on your assessment of these, what are some strategic options for Fitbit go...

    4. Perform a SWOT analysis for Fitbit. Based on your assessment of these, what are some strategic options for Fitbit going forward? 5. Analyze the company’s financial performance. Do trends suggest that Fitbit’s strategy is working? 6.What recommendations would you make to Fitbit management to address the most important strategic issues facing the company? Fitbit, Inc., in 2017: Can Revive Its Strategy and It Reverse Mounting Losses? connect ROCHELLE R. BRUNSON Baylor University MARLENE M. REED Baylor University in the...

  • Read the Article posted below, then answer the following questions: Mergers & acquisitions are a major...

    Read the Article posted below, then answer the following questions: Mergers & acquisitions are a major form of corporate diversification strategy, identify and discuss the top three reasons why most (50-60%) of acquisitions fail to create shareholder value. What are the five major components of “CEMEX Way” and why has this approach been so successful in post-acquisition integration? In your opinion, what can other companies learn from the “CEMEX Way” as a benchmark for acquisition management? Article: CEMEX: Globalization "The...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this p...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...

  • Required: 1. What is the amount of Apple’s accounts receivable as of September 30, 2017? 2....

    Required: 1. What is the amount of Apple’s accounts receivable as of September 30, 2017? 2. Compute Apple’s accounts receivable turnover as of September 30, 2017. 3. How long does it take, on average, for the company to collect receivables for fiscal year ended September 30, 2017? 4. Apple’s most liquid assets include (a) cash and cash equivalents, (b) short-term marketable securities, (c) accounts receivable, and (d) inventory. Compute the percentage that these liquid assets (in total) make up of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT