Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming You've been tasked by Happy Travel & Tours for creating a mileage claim system for the company's drivers. To compute the claim each

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Java Programming

You've been tasked by Happy Travel & Tours for creating a mileage claim system for the company's drivers. To compute the claim each day, the system needs the mileage as input. The following is how the claim is computed depending on the rate and range of kilometres: Kilometers Rates The first 500 km 501 km - 1000 km $ 0.70 1001 km and above $ 1.00 $ 0.50 Example: Mileage = 1200 500km x 1.00 = 500 500km X 0.70 = 350 200km x 0.50 = 100 Total claim = $ 950 The system should give option for the user to choose the desired operation that he would like to perform [1- Calculate Claims, 2-Display Report, 0 - Exit]. The user can repeat the calculation and display the report as they wish. The system will stop when the user chooses 0-Exit. Each time user chooses 1 (Calculate Claims), information about the claim including: Name of driver, number of claims and the total claim in THREE different arrays: 1) driverName, 2) noOfClaimsArray and 3) totalClaimArray. The report should be displayed as a table which includes the name, number of claims and the total claim for each driver, and the overall claim for all drivers. Your system should implement four methods as below: 1) displayMenu(): a void method which displays the menu and read user's choice of operation. 2) readInput(): a void method which keeps reading input from user until user chooses 'N'. The input that should be read are driver name, number of claims, the mileage each claim. After reading the input, method calculateClaim (noofClaims) should be called and the appropriate values . for should be sent to the method. The driver's name and number of claims should be directly inserted into the array. 3) calculateClaim (no0fClaims): a value returning method which calculates and returns the total claim for a driver. This method accepts one parameter which is number of claims. 4) displayReport(): a void method which traverse along the three arrays and displays the report (name, number of claims and total claim). It also calculates and displays the overall claim for all drivers. Sample run: =========== ===== >>>>> ====== Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 1 ================== ========= Enter the number of claims for Ahmed: 2 > Mileage in KM for claim 1:400 The amount for claim 1: 400.00 >> Mileage in KM for claim 2:800 The amount for claim 2: 710.00 Do you want to calculate claims for another driver? [Y/N]: Input name: Ali Enter the number of claims for Ali: 3 >> Mileage in KM for claim 1:1000 The amount for claim 1: 850.00 Mileage in KM for claim 2:500 The amount for claim 2 : 500.00 Mileage in KM for claim 3:600 The amount for claim 3: 570.00 A Do you want to calculate claims for another driver? [Y/N]: n Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 2 ========HAPPY TRAVEL & TOURS >> NAME NO OF CLAIMS TOTAL CLAIM 2 Ahmed Ali 1110.00 1920.00 3 The overall claims 3030.0 CEND REPORT Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 0 =========== ======= ================ >>> ==== Part of the codes are provided to you. Comments are given as a guidance to complete the code. import java.util.Scanner; public class claimArrayMethod ! public static Scanner scan = new Scanner(System.in); //static arrays declaration //static variables declaration // method displayMenu() to display the main menu //header of displayMenu() method / /body of displayMenu() method //end of displayMenu // method readInput() to read input and call method calculateClaim //header of readInput() method //appropriate variables declaration (if needed) System.out.println("EEEEEEE System.out.println(">>>>"); i //this do..while loop will repeat until the user chooses 'N' do //read input (driver's name, number of claims). Driver's name and number of claims are saved directly to arrays //call method calculateClaim and send appropriate values System.out.println(" //ask user whether would like to calculate claim for another driver or not System.out.println(" "); //add current driver counter while '>) }//end of read Input // method calculateClaim to calculate the claim and keep the calculated values in the appropriate array //header of calculateClaim method { //appropriate variable declaration (is needed) // formula to calculate claim //end of calculateClaim // method displayReport() to display all records available in the arrays //header of displayReport() method 1 //appropriate variable declaration (if needed) / /to print the label for the display table System.out.println("==========HAPPY TRAVEL & TOUR 3============="); System.out.println("> ; System.out.println(" "); System.out.printf("-14-14-12sen", "NAME", "NO OF CLAIMS", "TOTAL CLAIM"); System.out.println(" // or loop header to traverse along the arraysi //display the content of each array to form a report //end of for loop System.out.println(" System.out.println(" System.out.println(" }//end of display Report >>>>> System.out.println("=== //this do..while loop will repeat until user chooses o do! //method call to display main menu // Read user's choice. // This switch will call appropriate method as chosen by user // switch header // cases to call appropriate methods }//switch while (>); System.out.println(" =SES"); System.out.println(" >>>"); System.out.println(" //class i //main You've been tasked by Happy Travel & Tours for creating a mileage claim system for the company's drivers. To compute the claim each day, the system needs the mileage as input. The following is how the claim is computed depending on the rate and range of kilometres: Kilometers Rates The first 500 km 501 km - 1000 km $ 0.70 1001 km and above $ 1.00 $ 0.50 Example: Mileage = 1200 500km x 1.00 = 500 500km X 0.70 = 350 200km x 0.50 = 100 Total claim = $ 950 The system should give option for the user to choose the desired operation that he would like to perform [1- Calculate Claims, 2-Display Report, 0 - Exit]. The user can repeat the calculation and display the report as they wish. The system will stop when the user chooses 0-Exit. Each time user chooses 1 (Calculate Claims), information about the claim including: Name of driver, number of claims and the total claim in THREE different arrays: 1) driverName, 2) noOfClaimsArray and 3) totalClaimArray. The report should be displayed as a table which includes the name, number of claims and the total claim for each driver, and the overall claim for all drivers. Your system should implement four methods as below: 1) displayMenu(): a void method which displays the menu and read user's choice of operation. 2) readInput(): a void method which keeps reading input from user until user chooses 'N'. The input that should be read are driver name, number of claims, the mileage each claim. After reading the input, method calculateClaim (noofClaims) should be called and the appropriate values . for should be sent to the method. The driver's name and number of claims should be directly inserted into the array. 3) calculateClaim (no0fClaims): a value returning method which calculates and returns the total claim for a driver. This method accepts one parameter which is number of claims. 4) displayReport(): a void method which traverse along the three arrays and displays the report (name, number of claims and total claim). It also calculates and displays the overall claim for all drivers. Sample run: =========== ===== >>>>> ====== Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 1 ================== ========= Enter the number of claims for Ahmed: 2 > Mileage in KM for claim 1:400 The amount for claim 1: 400.00 >> Mileage in KM for claim 2:800 The amount for claim 2: 710.00 Do you want to calculate claims for another driver? [Y/N]: Input name: Ali Enter the number of claims for Ali: 3 >> Mileage in KM for claim 1:1000 The amount for claim 1: 850.00 Mileage in KM for claim 2:500 The amount for claim 2 : 500.00 Mileage in KM for claim 3:600 The amount for claim 3: 570.00 A Do you want to calculate claims for another driver? [Y/N]: n Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 2 ========HAPPY TRAVEL & TOURS >> NAME NO OF CLAIMS TOTAL CLAIM 2 Ahmed Ali 1110.00 1920.00 3 The overall claims 3030.0 CEND REPORT Enter your choice: 1-Calculate Claims 2-Display report 0-Exit: 0 =========== ======= ================ >>> ==== Part of the codes are provided to you. Comments are given as a guidance to complete the code. import java.util.Scanner; public class claimArrayMethod ! public static Scanner scan = new Scanner(System.in); //static arrays declaration //static variables declaration // method displayMenu() to display the main menu //header of displayMenu() method / /body of displayMenu() method //end of displayMenu // method readInput() to read input and call method calculateClaim //header of readInput() method //appropriate variables declaration (if needed) System.out.println("EEEEEEE System.out.println(">>>>"); i //this do..while loop will repeat until the user chooses 'N' do //read input (driver's name, number of claims). Driver's name and number of claims are saved directly to arrays //call method calculateClaim and send appropriate values System.out.println(" //ask user whether would like to calculate claim for another driver or not System.out.println(" "); //add current driver counter while '>) }//end of read Input // method calculateClaim to calculate the claim and keep the calculated values in the appropriate array //header of calculateClaim method { //appropriate variable declaration (is needed) // formula to calculate claim //end of calculateClaim // method displayReport() to display all records available in the arrays //header of displayReport() method 1 //appropriate variable declaration (if needed) / /to print the label for the display table System.out.println("==========HAPPY TRAVEL & TOUR 3============="); System.out.println("> ; System.out.println(" "); System.out.printf("-14-14-12sen", "NAME", "NO OF CLAIMS", "TOTAL CLAIM"); System.out.println(" // or loop header to traverse along the arraysi //display the content of each array to form a report //end of for loop System.out.println(" System.out.println(" System.out.println(" }//end of display Report >>>>> System.out.println("=== //this do..while loop will repeat until user chooses o do! //method call to display main menu // Read user's choice. // This switch will call appropriate method as chosen by user // switch header // cases to call appropriate methods }//switch while (>); System.out.println(" =SES"); System.out.println(" >>>"); System.out.println(" //class i //main

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

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago