The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
This is a program I recently wrote  and was wondering what the default protion would be? here is the program below,
package code_improvement;import java.util.Scanner;/**
 *
 * @author Brian
 */
public class Code_improvement {Â Â Â /**
    * @param args the command line arguments
    */
   public static void main(String[] args) {
        int n1, n2, opt, add, sub, mul;
       double div;
       Scanner Keyboard = new Scanner(System.in);
       System.out.println("Hello this program acts as a calculator");
       System.out.print("Enter first number:");
       n1 = Keyboard.nextInt();
       System.out.print("Enter second number:");
       n2 = Keyboard.nextInt();
       while(true)
       {
           System.out.println("Enter 1 for addition");
           System.out.println("Enter 2 for subtraction");
           System.out.println("Enter 3 for multiplication");
           System.out.println("Enter 4 for division");
           System.out.println("Enter 5 to Exit");
           opt = Keyboard.nextInt();
           switch(opt)
           {
               case 1:
               add = n1 + n2;
               System.out.println("Total Calculation:"+add);
               break;               case 2:
               sub = n1 - n2;
               System.out.println("Total Calculation:"+sub);
               break;               case 3:
               mul = n1 * n2;
               System.out.println("Total Calculation:"+mul);
               break;               case 4:
               div = (double)n1 / n2;
               System.out.println("Total Calculation:"+div);
               break;                case 5:
               System.exit(0);
               break;
           }