Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM STATEMENT The Starship Enterprise may be in difficulty! It has been ordered by Star Fleet to go on a peaceful scientific mission around the

PROBLEM STATEMENT

The Starship Enterprise may be in difficulty! It has been ordered by Star Fleet to go on a peaceful scientific mission around the planet Delta Tau. Unfortunately, the Deltoids are not a very nice life form. Captain James T. Kirk is worried that the planet's inhabitants may use their giant tractor beam in an attempt to pull the Enterprise down to the surface of the planet and destroy it! Naturally, the engines of the mighty Enterprise are strong enough to enable the ship to pull away from any known tractor beam. The only problem is whether or not there is enough anti-matter fuel in the engines to enable the ship to escape in time.

The amount of fuel required depends upon the altitude of the Enterprise and the strength of the tractor beam. If there is sufficient fuel, the Enterprise can escape as soon as it is attacked. If there is insufficient fuel, Captain Kirk must call down to the engine room and tell Scotty to start shoveling anti-matter into the engines.

Captain Kirk would like to know in advance what to expect if the ship is attacked. Since Commander Spock is off on vacation on a sunny beach on Planet Vulcan, it is necessary for you to write a program that will provide a minute-by-minute simulation of possible attack situations.

Write a C++ program to do the following:

1. Interactively request and read in the initial altitude (in Km) and fuel supply (in Kg) of the Enterprise as well as the strength of the Deltoid's tractor beam (in Km/min/min). Your program must allow someone entering these data items to do so repeatedly, allowing for multiple simulations. Do this by asking the user to enter a 'y' or 'n' before each simulation, indicating whether or not a new simulation should be run at that time.

2. Compute the amount of fuel required to escape from that altitude. The amount required can be calculated using this formula:

fuel_required = (1 - altitude / 200000) * beam_strength

3. If there is sufficient fuel available, recommend escaping at once.

4. If there is insufficient fuel available, advise Captain Kirk to turn off the engines and have Scotty start shoveling. If we don't turn off the engines, Scotty might get toasted when he opens the fuel door.

5. Your program should then display a minute-by-minute status report on the Enterprise's condition. This report should continue until the Enterprise has enough fuel to escape the planet, or the ship crashes.

6. Based on the results of your report, tell the Captain how long he should wait before starting the engines, or how long before the ship will crash.

You should implement your status report in the following way:

1. Initialize the time to zero

2. Now, while the amount of fuel is less than the amount of fuel required and the current altitude is greater than zero,

a) Add one to the time b) Compute the new current altitude using the formula:

altitude = altitude - beam_strength * time * time

c) Calculate the amount of fuel required to escape using this new altitude. Use the formula for the required fuel that was given above.

d) Compute the new amount of fuel in the engines by adding 10 Kg. to the previous amount. Scotty can shovel 10 Kg. of fuel per minute.

e) Print out the time, the current altitude, the fuel available, and the fuel required for escape.

Input/Output and Example Test Data Sets

As a minimum, test your program with the data sets shown in the example run output section below, i.e.:

 10000 100 100 10000 75 100 10000 25 100 

Of course, you may run the program with as many data sets as you choose, and it must work for any valid data set.

Your program must ask the user for a 'y' or 'n' (and allow for 'Y' or 'N' as well) to indicate whether or not a new simulation should be run. For this input item, check for input errors and allow the user to enter a character again if they do not enter a 'y' or 'n' correctly when asked. You may assume that the user enters a single character here.

Your program does not have to check for invalid non-numeric data entries, i.e. you may assume that the user will type in only valid integer values for the three numeric data entries. However, if they type in something like a negative number for the altitude, your program must re-prompt the user until he or she enters a value which is positive. Note that positive means greater than

zero. These three values input must be read and stored as integers.

Sample Run Output

The exact format of your output is up to you, but should be at least as easy to read as the following sample run:

**********************************************************************

DELTA TAU ESCAPE SIMULATION

**********************************************************************

Enter the current altitude of the ship: 10000

Enter the current fuel supply of the ship: 100

Enter the strength of the enemy tractor beam: 100

Simulation: *************** Computer Report on Ship Status ***********************

The Enterprise has gone into orbit around Delta Tau at an altitude of 10000 Km. It has a fuel supply of 100 Kg. of fuel. It has been attacked by a tractor beam of strength 100 Km/min/min.

At this altitude, 95.0 Kg. of fuel are required to escape. There is sufficient fuel to escape.

Recommendation: Start the engines and escape at once!

**********************************************************************

Do you want to run another simulation? y

Enter the current altitude of the ship: 10000 Enter the current fuel supply of the ship: 75 Enter the strength of the enemy tractor beam: 100

Simulation: *************** Computer Report on Ship Status ***********************

The Enterprise has gone into orbit around Delta Tau at an altitude of 10000 Km. It has a fuel supply of 75 Kg. of fuel. It has been attacked by a tractor beam of strength 100 Km/min/min.

At this altitude, 95.0 Kg. of fuel are required to escape. There is insufficient fuel to escape.

Recommendation: Tell Scotty to start shoveling! Report of what to expect:

TIME ALTITUDE FUEL AVAILABLE FUEL REQUIRED

--------------------------------------------------------------------------------------------------

1 min 9900 KM 85 KG 95.1 KG

2 min 9500 KM 95 KG 95.2 KG

3 min 8600 KM 105 KG 95.7 KG

In 3 minutes there will be sufficient fuel to escape. Recommend starting the engines at that time 

**********************************************************************

Do you want to run another simulation? y

Enter the current altitude of the ship: 10000 Enter the current fuel supply of the ship: 25 Enter the strength of the enemy tractor beam: 100

Simulation: *************** Computer Report on Ship Status ***********************

The Enterprise has gone into orbit around Delta Tau at an altitude of 10000 Km. It has a fuel supply of 25 Kg. of fuel. It has been attacked by a tractor beam of strength 100 Km/min/min.

At this altitude, 95.0 Kg. of fuel are required to escape.

There is insufficient fuel to escape.

Recommendation: Tell Scotty to start shoveling!

Report of what to expect:

TIME ALTITUDE FUEL AVAILABLE FUEL REQUIRED

--------------------------------------------------------------------------------------------

1 min 9900 KM 35 KG 95.1 KG 2 min 9500 KM 45 KG 95.2 KG 3 min 8600 KM 55 KG 95.7 KG 4 min 7000 KM 65 KG 96.5 KG 5 min 4500 KM 75 KG 97.8 KG 6 min 900 KM 85 KG 99.6 KG 7 min 0 KM 95 KG 100.0 KG 

In 7 minutes the ship will crash! Recommend sending a goodbye message to Star Fleet!

**********************************************************************

Do you want to run another simulation? n Goodbye and Good Luck at Delta Tau!

**********************************************************************

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

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions