Question

Ajax Food Delivery delivers single-serving food items to the Jacksonville metro area. The company employs multiple...

Ajax Food Delivery delivers single-serving food items to the Jacksonville metro area. The company employs multiple drivers, each of whom enter their delivery data once they arrive back at headquarters at the end of their shift.

Write a modular Java program which prompts a driver for their name and round-trip mileage for each delivery. The program should continue to prompt the driver for delivery data until they choose to exit by entering a mileage sentinel value of 0. Assume a maximum of 10 deliveries. The mileage values for each delivery must be stored in an array.

Once the driver chooses to exit the program by entering the sentinel value, display the total number of deliveries, the total mileage driven for the driver, and an itemized list of delivery mileage.

Your program must include a method which accepts an array parameter representing the delivery mileage values; this method must collect the driver's input . Additional methods may be helpful and are recommended.

In addition to the above requirements, your program must conform to the course programming rubric. An ID header is required, descriptive comments are required, indentation and alignment must be correct and consistent, and named constants should be used where appropriate.

Expected output shown below, user input is in red. You can assume the driver's information will be valid (no input validation is required).

Welcome to the Ajax Food Delivery Tracking System
Please enter your name: John Smith
Please enter the round-trip mileage for delivery 1: 20
Please enter the round-trip mileage for delivery 2: 14
Please enter the round-trip mileage for delivery 3: 16
Please enter the round-trip mileage for delivery 4: 0
Total Deliveries: 3
Total Mileage Driven: 50
Itemized Delivery Mileage:
Delivery 1:                         20
Delivery 2:                         14
Delivery 3:                         16
Thank you for using the Ajax Food Delivery Tracking System

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

If you have any doubts, please give me comment...

import java.util.Scanner;

public class FoodDelivery{

public static void main(String[] args) {

System.out.println("Welcome to the Ajax Food Delivery Tracking System");

Scanner in = new Scanner(System.in);

System.out.print("Please enter your name: ");

String name = in.nextLine();

int mileages[] = new int[10];

int n=0;

int temp, total_mileage = 0;

System.out.print("Please enter the round-trip mileage for delivery "+(n+1)+": ");

temp = in.nextInt();

while(temp!=0){

mileages[n] = temp;

total_mileage += temp;

n++;

System.out.print("Please enter the round-trip mileage for delivery "+(n+1)+": ");

temp = in.nextInt();

}

System.out.println("Total Deliveries: "+n);

System.out.println("Total Mileage Driven: "+total_mileage);

System.out.println("Itemized Delivery Mileage:");

for(int i=0; i<n;i++)

System.out.println("Delivery "+(i+1)+": \t"+mileages[i]);

System.out.println("Thank you for using the Ajax Food Delivery Tracking System");

}

}

Add a comment
Know the answer?
Add Answer to:
Ajax Food Delivery delivers single-serving food items to the Jacksonville metro area. The company employs multiple...
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
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