C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1

printf("4. Quit\n");


// The top-menu choice and the switch statement that makes the
// resulting
// information appear are encased in a do-while loop that
// ensures one
// of the 4 menu choices are made
do
{


printf("Enter your choice: ");
scanf(" %d", &choice1);
switch (choice1)
{
// In the first case, the user picked the 1980s. Now it
// time to see what specific info they need.


case (1):
{
printf("\n\nWhat would you like to see?\n");
printf("1. Baseball\n");
printf("2. The Movies\n");
printf("3. US Presidents\n");
printf("4. Quit\n");


printf("Enter your choice: ");
scanf(" %d", &choice2);


if (choice2 == 1)
{
printf("\n\nWorld Series Champions ");
printf("of the 1980s:\n");
printf("1980: Philadelphia Phillies\n");
printf("1981: Los Angeles Dodgers\n");
printf("1982: St. Louis Cardinals\n");
printf("1983: Baltimore Orioles\n");
printf("1984: Detroit Tigers\n");
printf("1985: Kansas City Royals\n");
printf("1986: New York Mets\n");
printf("1987: Minnesota Twins\n");
printf("1988: Los Angeles Dodgers\n");
printf("1989: Oakland A's\n");
printf("\n\n\n");
break;
} else if (choice2 == 2)
{
printf("\n\nOscar-Winning Movies in the 1980s:\n");
printf("1980: Ordinary People\n");
printf("1981: Chariots of Fire\n");
printf("1982: Gandhi\n");
printf("1983: Terms of Endearment\n");
printf("1984: Amadeus\n1985: Out of Africa\n");
printf("1986: Platoon\n");
printf("1987: The Last Emperor\n");
printf("1988: Rain Man\n");
printf("1989: Driving Miss Daisy");
printf("\n\n\n");
break;

Free download pdf