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: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
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;
}
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly