{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Example loop2

Example loop2 - Script started on Wed:38:49 2005 t...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Script started on Wed Feb 16 21:38:49 2005 %cat c53loop.c #include<stdio.h> #define HOUSTON_COST 100.00 #define SAN_ANTONIO_COST 150.00 #define PHOENIX_COST 200.00 #define LOS_ANGELES_COST 300.00 int main(void) { int id, count, num_houston; char destin, class; float cost; double totcost; printf("*******************************************************************\n"); printf(" Fly by Night Airlines Passenger List\n"); printf("Id Destin Class Fare\n"); printf("*******************************************************************\n"); count = 0; totcost = 0.0; num_houston = 0; while (count < 5) { scanf("%d %c %c", &id, &destin, &class); printf("%d", id); if ('H' == destin || 'h' == destin) { printf(" Houston "); cost = HOUSTON_COST; num_houston++; } else if ('S' == destin || 's' == destin) { cost = SAN_ANTONIO_COST;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
printf(" San Antonio"); } else if ('L' == destin || 'l' == destin) { printf(" Los Angeles"); cost = LOS_ANGELES_COST; } else { cost = PHOENIX_COST; printf(" Phoenix "); } if ('f' == class || 'F' == class) { printf(" First Class"); cost = cost * 1.5; } else if ('A' == class || 'a' == class) {
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern