Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following program in JAVA . I have a delivery company transporting goods in trucks. Each day the company has at least 2 trucks

Complete the following program in JAVA.

I have a delivery company transporting goods in trucks. Each day the company has at least 2 trucks available for transporting the goods.

The trucks are either large trucks or small trucks or a combination of large/small trucks.

The maximum number of goods the large truck can carry is 100 goods.

The maximum number of goods the small truck can carry is 10 goods.

A truck can't carry more than the maximum number of goods.

A truck can't carry less than 0 goods.

The program should allow the company to:

1. Enter the numeric value of the number of trucks he has for the day.

a. If it is less than 2, display a message then exit the program.

2. Enter the string "large" or "small" for the size of each truck he has for the day.

b. If the user enters an incorrect string, display a message and then allow them to reenter the size for that truck.

3. Enter the actual number of goods each truck is carrying. If it is less than zero or greater than maximum number of goods, display a message then allow them to reenter the actual number of goods the truck is carrying.

4. Calculate the percentage of load capacity of each truck, that is actual/maximum * 100. Display the information in a line for each truck.

a. Give the truck number, the maximum number of goods it can carry, the actual number goods the truck is carrying and the percentage load capacity.

A sample output should look similar to this:

How many trucks are operating today? 2

What is the size of truck 1? large

What is the actual number of goods for truck 1? 85

What is the size of truck 2? small

What is the actual number of goods for truck 2? 10

Report:

Truck 1 max: 100 actual: 85 capacity at: 85%

Truck 2 max: 10 actual: 10 capacity at: 100%

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

Students also viewed these Databases questions