: YOU MUST USE SWITCH STATEMENTS TO SOLVE THE NEXT TWO PROBLEMS
DO NOT USE LOOPS!
For this problem you must run the program to show all of your menu options working, just like with Problem 1, you will have a screen shot for every menu option and then you will have a screen shot for entering a value that is not part of the menu option.
Write a program that displays the following menu to the user: Welcome to learning basic Spanish! Please select the phrase you would like to learn today from the following choices: 1. 2. 3. 4. 5. 6. Quit Enter your choice (1-6): Note: The numbers above are blank, because you are to select FIVE English phrases form the table found below. When the user selects a menu option, the Spanish translation should be displayed to them. Do not worry about displaying accent marks. If the user enters 6, the program should end. Input Validation: Display an error message if the user enters a number outside the range of 1 through 6 when selecting an item from the menu.
Good morning. Buenos días.
Good afternoon. Buenas tardes.
Good evening. (greeting) Buenas noches.
I am fine. Estoy bien.
Nice to meet you. Mucho gusto.
See you later. Hasta luego.
Here I am providing the answer for the above problem:
Code:
#include <stdio.h>
int main()
{
int ch;
printf("Welcome to learning basic Spanish!\nPlease select the
phrase you would like to learn today from the following choices: 1.
2. 3. 4. 5. 6.\nQuit Enter your choice (1-6):");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Good morning. Buenos días.\n");
break;
case 2:
printf("Good afternoon. Buenas tardes.\n");
break;
case 3:
printf("Good evening. (greeting) Buenas noches.\n");
break;
case 4:
printf("I am fine. Estoy bien.\n");
break;
case 5:
printf("Nice to meet you. Mucho gusto.\n");
break;
case 6:
printf("See you later. Hasta luego.\n");
break;
default:
printf("This number is not in the range of 1-6.\n");
}
}
Screenshot of Code:
Output:
1.
2.
3.
4.
5.
6.Error Case:
Hoping that the above answer will help you...Thank you...
Get Answers For Free
Most questions answered within 1 hours.