Question

How do I turn this into a code I am super stuck please help!!!! ********************************************************************** DELTA...

How do I turn this into a code I am super stuck please help!!!!

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

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!

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

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

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int altitude=0, fuel=0, beam_strength=0, time;
    float fuel_required;
    char choice;
    cout << fixed << setprecision(1) ;
    cout << "**********************************************************************\n";
    cout << "DELTA TAU ESCAPE SIMULATION\n";
    cout << "**********************************************************************\n";
    while(1){
        cout << "Enter the current altitude of the ship: ";
        cin >> altitude;
        while(altitude < 0){
            cout << "Wrong input! Enter the current altitude of the ship: ";
            cin >> altitude;
        }
        cout << "Enter the current fuel supply of the ship: ";
        cin >> fuel;
        while(fuel < 0){
            cout << "Wrong input! Enter the current fuel supply of the ship: ";
            cin >> fuel;
        }
        cout << "Enter the strength of the enemy tractor beam: ";
        cin >> beam_strength;
        while(beam_strength < 0){
            cout << "Wrong input! Enter the strength of the enemy tractor beam: ";
            cin >> beam_strength;
        }
        fuel_required = (1 - (float)altitude / 200000) * beam_strength;

        cout << "Simulation:\n";
        cout << "*************** Computer Report on Ship Status ***********************\n" ;
        cout << "The Enterprise has gone into orbit around Delta Tau at an altitude of " << altitude << " Km.\n" ;
        cout << "It has a fuel supply of " << fuel << " Kg. of fuel.\n" ;
        cout << "It has been attacked by a tractor beam of strength " << beam_strength << " Km/min/min.\n" ;
    
        time = 0;
        if(fuel >= fuel_required){
            cout << "At this altitude, " << fuel_required << " Kg. of fuel are required to escape. There is sufficient fuel to escape.\n";
            cout << "Recommendation: Start the engines and escape at once!\n";
        }
        else{
            cout << "At this altitude, " << fuel_required << " Kg. of fuel are required to escape. There is insufficient fuel to escape.\n";
            cout << "Recommendation: Tell Scotty to start shoveling! Report of what to expect:\n";
            cout << "TIME\tALTITUDE\tFUEL AVAILABLE\tFUEL REQUIRED\n";
            cout << "--------------------------------------------------------------------------------------------------\n";
            while (fuel < fuel_required){
                time++ ;
                altitude = altitude - beam_strength * time * time ;
                fuel_required = (1 - (float)altitude / 200000) * beam_strength ;
                if (altitude < 0)
                    altitude = 0;
                if (fuel_required > 100)
                    fuel_required = 100;
                fuel += 10;
                cout << time << " mins\t" << altitude << " KM\t" << fuel << " KG\t" << fuel_required << " KG\n";
                if(altitude <= 0){
                    cout << "\nIn " << time << " minutes the ship will crash! \nRecommend sending a goodbye message to Star Fleet!\n";
                    break;
                }
            }
            if (fuel >= fuel_required)
                cout << "In " << time << " minutes there will be sufficient fuel to escape.\nRecommend starting the engines at that time \n";
        }
        cout << "**********************************************************************\n";
    
        cout << "Do you want to run another simulation? ";
        cin >> choice;
        while (choice != 'n' && choice != 'N' && choice != 'y' && choice != 'Y'){
            cout << "Wrong input. Please enter y or n: ";
            cin >> choice;
        }
        if(choice == 'n' || choice == 'N'){
            cout << "Goodbye and Good Luck at Delta Tau!\n";
            cout << "**********************************************************************";
            break;
        }
    }
    return 0;
}

Add a comment
Know the answer?
Add Answer to:
How do I turn this into a code I am super stuck please help!!!! ********************************************************************** DELTA...
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
  • PROBLEM STATEMENT The Starship Enterprise may be in difficulty! It has been ordered by Star Fleet...

    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...

  • Please help with my car traffic simulator! Code that I already have below, I do not know how to...

    Please help with my car traffic simulator! Code that I already have below, I do not know how to start it off! public class IntersectionSimulation { private final static int EAST_WEST_GREEN_TIME = 30 ; private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ; private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ; private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ; private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...

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