Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class MultiSaludo {
- public static void main (String[] args) {
- int opcion = 0;
- String saludo[] = {
- "Buenos días, Buenas tardes, Buenas noches",
- "Good Morning, Good Afternoon, GoodNight",
- "Bonjour, Bon après midi, Bonne Nuit",
- "Guten Morgen, Guten Tag, Gute Nacht",
- "Buongirono, Buon Pomeriggio, Buonanotte",
- "Eres de otra nación del mundo"};
- Scanner resp = new Scanner(System.in);
- boolean continua = true;
- do {
- try {
- System.out.println("¿De qué nacionalidad eres?");
- System.out.println();
- System.out.println("Opciones: "
- + "1 = Española, "
- + "2 = Inglesa, "
- + "3 = Francesa, "
- + "4 = Alemana, "
- + "5 = Italiana");
- opcion = resp.nextInt();
- continua = false;
- } // end try
- catch (InputMismatchException inputMismatchException) {
- //System.err.printf("\nExcepción: %s", inputMismatchException);
- resp.nextLine();
- System.out.println("\nNo has ingresado una opción válida.\n\n");
- } // end catch
- } while (continua);
- switch (opcion) {
- case 1:
- System.out.println(saludo[0]);
- break;
- case 2:
- System.out.println(saludo[1]);
- break;
- case 3:
- System.out.println(saludo[2]);
- break;
- case 4:
- System.out.println(saludo[3]);
- break;
- case 5:
- System.out.println(saludo[4]);
- break;
- default:
- System.out.println(saludo[5]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement