Morgan\'s Department Store distributes bonuses to its salespeople after the holi
ID: 3820850 • Letter: M
Question
Morgan's Department Store distributes bonuses to its salespeople after the holiday rush. The table below shows the bonuses, which are based on full weeks worked during the season and the number of positive online customer reviews. Write a program in Java Language that allows a user to continuously enter values for the two bonus-determining factors and displays the appropriate bonus. Save the file as MorgansBonuses.java.
Morgan's Department Store bonuses
Positive Reviews Received
Full Weeks Worked
0
1
2
3
4 or More
0
5.00
9.00
16.00
22.00
30.00
1
10.00
12.00
18.00
24.00
36.00
2
20.00
25.00
32.00
42.00
53.00
3
32.00
38.00
45.00
55.00
68.00
4
46.00
54.00
65.00
77.00
90.00
5
60.00
72.00
84.00
96.00
120.00
6 or more
85.00
100.00
120.00
140.00
175.00
Positive Reviews Received
Full Weeks Worked
0
1
2
3
4 or More
0
5.00
9.00
16.00
22.00
30.00
1
10.00
12.00
18.00
24.00
36.00
2
20.00
25.00
32.00
42.00
53.00
3
32.00
38.00
45.00
55.00
68.00
4
46.00
54.00
65.00
77.00
90.00
5
60.00
72.00
84.00
96.00
120.00
6 or more
85.00
100.00
120.00
140.00
175.00
Explanation / Answer
import java.util.Scanner;
/**
*
* @author prmsh
*/
public class MorgansBonuses {
//vairables declared
int weeks;
int hours;
//array chart declaring
double[][] bonusData = {{5,9,16,22,30}, {10,12,18,24,36}, {20,25,32,42,53},{32,38,45,55,68},{46,54,65,77,90},{60,70,84,96,120},{85,100,120,140,175}};
public MorgansBonuses(int weeks, int hours) {
this.weeks = weeks;
this.hours = hours;
}
//getter setter methods
public int getWeeks() {
return weeks;
}
public void setWeeks(int weeks) {
this.weeks = weeks;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
//printing pay for the user by checking weeks and hours
public void print(){
if(weeks >=6){
if(hours>=4){
System.out.println("Your pay: "+bonusData[6][4]);
}
else{
System.out.println("Your pay: "+bonusData[6][this.hours]);
}
}
else{
if(hours>=4){
System.out.println("Your pay: "+bonusData[this.weeks][4]);
}
else{
System.out.println("Your pay: "+bonusData[this.weeks][this.hours]);
}
}
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int weeks,hours;
for(int i=0;i<2;i++){
//reading data from user
System.out.println("Enter Weeks: ");
weeks = sc.nextInt();
System.out.println("Enter Hours: ");
hours = sc.nextInt();
//creaitng objects
MorgansBonuses obj = new MorgansBonuses(weeks,hours);
//printing objects
obj.print();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.