Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question :(Supposed to run on codeblocks, i\'m using a mac and it\'s not working

ID: 3668679 • Letter: Q

Question

Question :(Supposed to run on codeblocks, i'm using a mac and it's not working to well for me so i've been using codeblocks, but if you do have codeblocks or windows in general, would be great to fix my mistakes and make sure it runs on a complier on your computer :) )

You love to travel, but hate to fly ... really hate to fly! The longer you are on an airplane, the less comfortable you become. Actually, most people do too, but you become particularly uncomfortable, on an exponential basis. So, in order to know how long flights are, you build a computer program that for a handful of cities and aircraft types, it will tell you the duration of the flight in hours and minutes. So, use Code::Blocks to write and execute the following simple program:

Write a program that requests from the user the name of the city to which she/he wants to fly. The user is requested to enter the destination city and the type of aircraft to be flown. This should be entered from the keyboard using a character or an integer entry. The program then proceeds to calculate and print out the flight time in whole hours and minutes based on the distance from Orlando to that city and the speed of the chosen airplane. For the purpose of our program here, you will use the following cities:

New York Paris
London Rome Frankfurt
San Francisco Tokyo Havana

Search the web (Google Maps?) and find the distances between these cities and Orlando. Cite the sources on comment lines.

Of course, you will be able to also enter the type of airplane on which you will be traveling. Then the program will ask the user what kind of airplane he/she will be flying. For the purposes of this program, use the following aircraft:

Boeing 747 Boeing 777 Airbus A330 Airbus A380 Concorde

Search the web for the cruising airspeed of these aircraft, and cite the sources in comment lines. Make the output friendly. It should state the entire set of inputs and the output, for example,

You must use preprocessor directives (#define) to define the constant values of the distances and speeds. You must also use a switch and an if/elseif/.../else structure in this program.

my code so far (which doesn't complile)

#include <stdio.h>

#define Newyork 947

#define Paris 4503

#define London 4333

#define Rome 5114

#define Frankfurt 7627

#define SanFrancisco 2445

#define Tokyo 7278

#define Havana 382

//http://www.airmilescalculator.com

#define B747 570

#define B777 590

#define A330 657

#define A380 634

#define Concorde 1354

int main ()

{

  

  

  

char city;

printf("Please enter the city to which you would like to fly ");

printf("Enter the first character of the name of the city in lower case letter ");

scanf("%c" , &city);

  

  

  

int distance;

switch (city) {

case 'n':

distance = Newyork;

break;

  

case 'p':

distance = Paris;

break;

  

case 'l':

distance = London;

break;

  

case 'r':

distance = Rome;

break;

  

case 'f':

distance = Frankfurt;

break;

  

case 's':

distance = SanFrancisco;

break;

  

case 't':

distance = Tokyo;

break;

  

case 'h':

distance = Havana;

break;

  

  

default: {

printf("You've made an error");

  

return 0;

  

  

}

  

  

int vel;

printf("Enter the following values for the type of aircraft to be flown: ");

printf(" Enter 1 if Boeing 747 ");

printf(" Enter 2 if Boeing 777 ");

printf(" Enter 3 if Airbus 330 ");

printf(" Enter 4 if Airbus 380 ");

printf(" Enter 5 if Concorde ");

scanf("%d" , &vel);

  

  

  

int speed;

if (vel==1)

speed = B747;

  

else if (vel==2)

speed = B777;

  

else if (vel==3)

speed = A330;

  

else if (vel==4)

speed = A380;

  

else if (vel==5)

speed = Concorde;

  

else {

printf("Your entry is meaningless, Run the program again. ;");

  

}

int flight_hours;

flight_hours= distance/speed;

  

  

int flight_minutes;

flight_minutes = ((float) (distance%speed) /

(float)speed)*60.;

Explanation / Answer

#include <stdio.h>
#define Newyork 947
#define Paris 4503
#define London 4333
#define Rome 5114
#define Frankfurt 7627
#define SanFrancisco 2445
#define Tokyo 7278
#define Havana 382
//http://www.airmilescalculator.com
#define B747 570
#define B777 590
#define A330 657
#define A380 634
#define Concorde 1354
int main (){
    char city;
    printf("Please enter the city to which you would like to fly ");
    printf("Enter the first character of the name of the city in lower case letter ");
    scanf("%c" , &city);
  
    int distance;
    switch (city) {
        case 'n':
            distance = Newyork;
            break;
          
        case 'p':
            distance = Paris;
            break;
          
        case 'l':
            distance = London;
            break;
          
        case 'r':
            distance = Rome;
            break;
          
        case 'f':
            distance = Frankfurt;
            break;
          
        case 's':
            distance = SanFrancisco;
            break;
          
        case 't':
            distance = Tokyo;
            break;
          
        case 'h':
            distance = Havana;
            break;
          
          
        default: {
            printf("You've made an error");
          
            return 0;
          
          
        }
     }
          
          
    int vel;
    printf("Enter the following values for the type of aircraft to be flown: ");
    printf(" Enter 1 if Boeing 747 ");
    printf(" Enter 2 if Boeing 777 ");
    printf(" Enter 3 if Airbus 330 ");
    printf(" Enter 4 if Airbus 380 ");
    printf(" Enter 5 if Concorde ");
    scanf("%d" , &vel);
          
          
          
    int speed;
    if (vel==1)
        speed = B747;
  
    else if (vel==2)
        speed = B777;
  
    else if (vel==3)
        speed = A330;
  
    else if (vel==4)
        speed = A380;
  
    else if (vel==5)
        speed = Concorde;
  
    else {
        printf("Your entry is meaningless, Run the program again. ;");
      
    }
    int flight_hours;
    flight_hours= distance/speed;
  
  
    int flight_minutes;
    flight_minutes = ((float) (distance%speed) /
                      (float)speed)*60.;

     printf("The flight time between Orlando and your city of choice will be %d hours and %d minutes;",flight_hours, flight_minutes);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote