Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Jacob Smith
Added: Jun 5, 2021 6:04 PM
Views: 379
Tags: switch
  1.         // Scanner object for keyboard input
  2.         Scanner keyboardInput = new Scanner(System.in);
  3.  
  4.         // Prompt the user to select an option
  5.         System.out.println("\nType an option to perform the operation\n" +
  6.             "   Option 1:  Convert Units of Length\n" +
  7.             "   Option 2:  Convert Units of  Weight\n" +
  8.             "   Option 3:  Convert Units of Area\n" +
  9.             "   Option 4:  Convert Units of Volume\n" +
  10.             "   Option 5:  Convert Units of  Weight (Capacity)\n" +
  11.             "   Option 6:  Calculate the Variance  of Four Scores\n" +
  12.             "   Option 7:  Calculate the Standard Deviation of Four Scores\n" +
  13.             "   Option 8:  Calculate the Simple Interest on a Loan\n" +
  14.             "   Option 9:  Calculate the Compound Interest on a Loan\n" +
  15.             "   Option 10: End the Program\n");
  16.  
  17.         optionSelected = keyboardInput.nextInt();
  18.         keyboardInput.nextLine();  //Consume enter key
  19.        
  20.         while (optionSelected != 10)
  21.         {
  22.           switch(optionSelected)
  23.           {
  24.             case 1:
  25.              
  26.               break;
  27.  
  28.             case 2:
  29.  
  30.               break;
  31.            
  32.             case 3:
  33.  
  34.               break;
  35.  
  36.             case 4:
  37.              
  38.               break;
  39.  
  40.             case 5:
  41.  
  42.              break;
  43.  
  44.             case 6:
  45.            
  46.             break;
  47.  
  48.             case 7:
  49.            
  50.             break;        
  51.  
  52.             case 8:
  53.            
  54.             break;
  55.  
  56.             case 9:
  57.            
  58.             break;
  59.  
  60.             case 10:
  61.             break;
  62.            
  63.            default:
  64.               System.out.println("Enter a number from 1 to 10 only ");
  65.                
  66.         } // End of the switch statement
  67.          
  68.         // Prompt the user to select an option
  69.         System.out.println("\nType an option to perform the operation\n" +
  70.             "   Option 1:  Calculate Gross Pay\n" +
  71.             "   Option 2:  Calculate Net Profit\n" +
  72.             "   Option 3:  Calculate Net Price\n" +
  73.             "   Option 4:  Calculate the Summation of Two Test Scores\n" +
  74.             "   Option 5:  Calculate the Average   of Three Test Scores\n" +
  75.             "   Option 6:  Calculate the Variance  of Four Scores\n" +
  76.             "   Option 7:  Calculate the Standard Deviation of Four Scores\n" +
  77.             "   Option 8:  Calculate the Simple Interest on a Loan\n" +
  78.             "   Option 9:  Calculate the Compound Interest on a Loan\n" +
  79.             "   Option 10: End the Program\n");
  80.    
  81.         optionSelected = keyboardInput.nextInt();
  82.         keyboardInput.nextLine();  //Consume enter key
  83.        
  84.         } // End of the while statement
  85.