Site hosted by Angelfire.com: Build your free website today!

PROGRAM #14
 

 

 

 

 

 


                        Using a MENU and strings and switch

You need to calculate the price of a flight.  There are many factors needed to do this calculation.

* Have the person select the city they will fly to from Detroit (there will be five choices; Cleveland, Chicago, New York, Los Angeles, and Miami).

*Each city has a different airport landing fee (Cleveland=$15, Chicago=$20, New York=$60, Los Angeles=$20, and Miami=$18).

*The fee has a distance cost per mile as well.  (Cleveland is 180 miles @ 90 cents per mile, Chicago is 299 miles @ 75 cents per mile, New York is 435 miles @ 60 cents per mile, Los Angeles is 2100 miles @ 20 cents per mile and Miami is 1220 miles @ 30 cents per mile.)

Detroit charges tax on all tickets purchased (9% of the total) and a service charge of $12 per ticket.

Have a MENU with these choices…

TICKET FOR CUSTOMER: Le Monjello

Sex: male

Landing Fee:     $20.00

            Distance Fee:    $224.25

            Tax:                  $21.98

            Service:            $12.00

            SUB TOTAL   $278.23

Male Discount (05%) $-13.91

PAY THIS AMOUNT: $264.32

Have a good time in CHICAGO.

 

TRAVEL COST CALCULATIONS

  1. Cleveland
  2. Chicago
  3. New York
  4. Los Angeles
  5. Miami
  6. Quit

Enter the number of your choice_2

 
                                                                                 

                                                                                   

 

 

 

 

 

 

 

 

 

Ask name and sex, and then start a switch that will have each city as a case.

  Switch (ch)

{ case 1: dist=180*90;

               landing= 15; 

               strcpy (dest, “Cleveland”);

               break;

Inside the switch, get a distance and landing fee for the particular city.

Calculate tax (9%) outside the switch.

Add service charge after tax.

Calculate sex charge or sex discount (male is discount of 5%, female is surcharge of 12%)

            Use an if           if (sex==’m’) {discount=-1*sub*.05;

                                                            Strcpy (status, “male discount (05%)”);

                                              Else      {discount= .12*sub;

                                                            Strcpy (status, “female surcharge (12%);

                                                            }