[Solved]Topics Assignment Give Practice Interactive Programs Else Statements Methods Return Values Q37241768



Topics This assignment will give you practice with interactive programs, if/else statements and methods that return values. Instructions Your program will prompt the user for information about two weeks worth of driving for Uber and Lyft, compute the earnings for each week, and then determine which week had higher earnings. For each week, we prompt for the service that the driver drove for (Uber or Lyft), information for calculating earnings for that service, and any tips that were earned. This information is used to calculate the total earnings for each of the two weeks, the total earnings for the two week period, and an assessment of which week earned more income. Calculating Earnings For each of the two weeks, the program will ask the user which service they drove for. We will assume that the driver drives for only one service for the entirety of the week although this would probably not be true in real life. Base earnings For both services, you will calculate the base pay for the week according to the formula: BASE PAY·$1.35 . MILES DRIVEN + $0.24 * MINUTES DRIVING Extra earnings Each service, however, has a different calculation for extra earnings. In the case of driving for Uber, the driver receives an additional 20% if they have accepted 95% or more of their ride requests. In the case of driving for Lyft, riders may tip and the driver receives 100% of tips. Output Printing of earnings Your program is to report the base and extra earnings and, later, the overall earnings for each week. These should be rounded to two decimal places when displayed. Hint: use printf Which week earned more? In addition to reporting the earnings for each week, the program should also produce whichever of the following messages is appropriate . You earned more in week 1 . You earned more in week 1 . You earned the same amount both weeks Other Requirements You should use static methods to eliminate redundant code and to break the problem up into logical subtasks. This includes making methods that return data and methods that take data as a parameter . . Your main method should be short so that a person can easily see the overall structure of the . You are to introduce at least five static methods other than main to break this problem up into In this program, none of your methods should have more than 15 lines of code in the body of the program. smaller subtasks and you should make sure that no single method is doing too much work. method (not counting blank lines or lines with just curly braces on them). The 15-line limitation is a special requirement for this assignment to force you to practice breaking up a program into methods. Be sure to once again include a short comment at the beginning of your program as well as a short comment for each method describing what it does. You do not have to perform any error checking. We will assume that the user enters numbers that are in the appropriate range. You should avoid “chaining” long sequences of method calls together without returning to main. Note that because this program involves both integer data and real data, you need to use appropriate type declarations (type int and calls on nextlnt for integer data, type double and calls on nextDouble for real-valued data). . . . . You should not be using for loops as a way to solve this problem. Sample Output Sample 1 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft Information for Week #1: did you drive for 1) Uber or 2) Lyft? 1 How many miles did you drive this week? 400 How many hours did you drive this week? 37.5 — Base earnings $1080.00 — What was your drive acceptance rate? 96 — Extra earnings $216.00 Information for Week #2: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 393 How many hours did you drive this week? 36 — Base earnings $1048.95 – How much did you earn in tips? 375 — Extra earnings $375.00 — Week 1 Earnings $1296.00 Week 2 Earnings$1423.95 You earned more in week 2 Total Earnings-$2719.95 Sample 2 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft. Information for Week #1: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 100 How many hours did you drive this week? 8 -Base earnings $250.20- How much did you earn in tips? 249 -Extra earnings $249.00- Information for Week #2: did you drive for 1) Uber or 2) Lyft? 1 How many miles did you drive this week? 206 How many hours did you drive this week? 17 -Base earnings $522.90- What was your drive acceptance rate? 85 – – Extra earnings $0.00 — Week 1 Earnings-$499.20 eek 2 Earnings-$522.90 You earned more in week 2 Total Earnings-$1022.10 Sample 3 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft. Information for Week #1: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 1 How many hours did you drive this week? 1 -Base earnings $27.90- How much did you earn in tips? 9.9 -Extra earnings $9.90- Information for Week #2: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 12 How many hours did you drive this week? 1.5 -Base earnings $37.80- How much did you earn in tips? 0 – – Extra earnings $0.00 — Week 1 Earnings-$37.80 eek 2 Earnings-$37.80 You earned the same amount both weeks Total Earnings-$75.60 Show transcribed image text Topics This assignment will give you practice with interactive programs, if/else statements and methods that return values. Instructions Your program will prompt the user for information about two weeks worth of driving for Uber and Lyft, compute the earnings for each week, and then determine which week had higher earnings. For each week, we prompt for the service that the driver drove for (Uber or Lyft), information for calculating earnings for that service, and any tips that were earned. This information is used to calculate the total earnings for each of the two weeks, the total earnings for the two week period, and an assessment of which week earned more income. Calculating Earnings For each of the two weeks, the program will ask the user which service they drove for. We will assume that the driver drives for only one service for the entirety of the week although this would probably not be true in real life. Base earnings For both services, you will calculate the base pay for the week according to the formula: BASE PAY·$1.35 . MILES DRIVEN + $0.24 * MINUTES DRIVING Extra earnings Each service, however, has a different calculation for extra earnings. In the case of driving for Uber, the driver receives an additional 20% if they have accepted 95% or more of their ride requests. In the case of driving for Lyft, riders may tip and the driver receives 100% of tips. Output Printing of earnings Your program is to report the base and extra earnings and, later, the overall earnings for each week. These should be rounded to two decimal places when displayed. Hint: use printf Which week earned more? In addition to reporting the earnings for each week, the program should also produce whichever of the following messages is appropriate . You earned more in week 1 . You earned more in week 1 . You earned the same amount both weeks
Other Requirements You should use static methods to eliminate redundant code and to break the problem up into logical subtasks. This includes making methods that return data and methods that take data as a parameter . . Your main method should be short so that a person can easily see the overall structure of the . You are to introduce at least five static methods other than main to break this problem up into In this program, none of your methods should have more than 15 lines of code in the body of the program. smaller subtasks and you should make sure that no single method is doing too much work. method (not counting blank lines or lines with just curly braces on them). The 15-line limitation is a special requirement for this assignment to force you to practice breaking up a program into methods. Be sure to once again include a short comment at the beginning of your program as well as a short comment for each method describing what it does. You do not have to perform any error checking. We will assume that the user enters numbers that are in the appropriate range. You should avoid “chaining” long sequences of method calls together without returning to main. Note that because this program involves both integer data and real data, you need to use appropriate type declarations (type int and calls on nextlnt for integer data, type double and calls on nextDouble for real-valued data). . . . . You should not be using for loops as a way to solve this problem. Sample Output Sample 1 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft Information for Week #1: did you drive for 1) Uber or 2) Lyft? 1 How many miles did you drive this week? 400 How many hours did you drive this week? 37.5 — Base earnings $1080.00 — What was your drive acceptance rate? 96 — Extra earnings $216.00 Information for Week #2: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 393 How many hours did you drive this week? 36 — Base earnings $1048.95 – How much did you earn in tips? 375 — Extra earnings $375.00 — Week 1 Earnings $1296.00 Week 2 Earnings$1423.95 You earned more in week 2 Total Earnings-$2719.95
Sample 2 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft. Information for Week #1: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 100 How many hours did you drive this week? 8 -Base earnings $250.20- How much did you earn in tips? 249 -Extra earnings $249.00- Information for Week #2: did you drive for 1) Uber or 2) Lyft? 1 How many miles did you drive this week? 206 How many hours did you drive this week? 17 -Base earnings $522.90- What was your drive acceptance rate? 85 – – Extra earnings $0.00 — Week 1 Earnings-$499.20 eek 2 Earnings-$522.90 You earned more in week 2 Total Earnings-$1022.10 Sample 3 This program compares the earnings of two weeks worth of driving for the ride share services Uber and Lyft. Information for Week #1: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 1 How many hours did you drive this week? 1 -Base earnings $27.90- How much did you earn in tips? 9.9 -Extra earnings $9.90- Information for Week #2: did you drive for 1) Uber or 2) Lyft? 2 How many miles did you drive this week? 12 How many hours did you drive this week? 1.5 -Base earnings $37.80- How much did you earn in tips? 0 – – Extra earnings $0.00 — Week 1 Earnings-$37.80 eek 2 Earnings-$37.80 You earned the same amount both weeks Total Earnings-$75.60
Expert Answer
Answer to Topics This assignment will give you practice with interactive programs, if/else statements and methods that return valu… . . .
OR

