Advertisement
Guest User

SimpleCalc

a guest
Nov 28th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. package simplecalc;
  2.  
  3. /**
  4.  *
  5.  * @author Jimmy
  6.  */
  7.  
  8. import java.util.Scanner;
  9.  
  10. public class SimpleCalc {
  11.  
  12.     /**
  13.      * @param args the command line arguments
  14.      */
  15.     public static void main(String[] args) {
  16.         Scanner user_input = new Scanner(System.in);
  17.  
  18.        
  19.         String whatMath;
  20.        
  21.                     System.out.print("Multiply, divide, add or subtract?");
  22.        
  23.             whatMath = user_input.next();
  24.        
  25.                     System.out.println("You chose to " + "["+whatMath+"]");
  26.        
  27.         int numberOne;
  28.        
  29.                     System.out.print("Enter any number...");
  30.        
  31.             numberOne = user_input.nextInt();
  32.        
  33.                     System.out.print("You entered: " + "["+numberOne+"]" );
  34.              
  35.         int numberTwo;
  36.        
  37.                     System.out.print("Enter another number...");
  38.                
  39.             numberTwo = user_input.nextInt();
  40.        
  41.                     System.out.println("You also entered: " + "["+numberTwo+"]");
  42.        
  43.         if("multiply".equalsIgnoreCase(whatMath)){
  44.            
  45.             int multiSum = numberOne * numberTwo;
  46.            
  47.                     System.out.println("So " + numberOne + " * " + numberTwo);
  48.                    
  49.                     System.out.println("The sum of your problem is: " + multiSum);
  50.            
  51.         }else if("divide".equalsIgnoreCase(whatMath)){
  52.            
  53.             int divideSum = numberOne / numberTwo;
  54.            
  55.                     System.out.println("So " + numberOne + " / " + numberTwo);
  56.                    
  57.                     System.out.println("The sum of your problem is: " + divideSum);
  58.                    
  59.         }else if("add".equalsIgnoreCase(whatMath)){
  60.            
  61.             int addSum = numberOne + numberTwo;
  62.            
  63.                     System.out.println("So " + numberOne + " + " + numberTwo);
  64.                    
  65.                     System.out.println("The sum of your problem is: " + addSum);
  66.                    
  67.         }else if("subtract".equalsIgnoreCase(whatMath)){
  68.            
  69.             int minusSum = numberOne - numberTwo;
  70.            
  71.                     System.out.println("So " + numberOne + " - " + numberTwo);
  72.                    
  73.                     System.out.println("The sum of your problem is: " + minusSum);
  74.         }
  75.        
  76.                    
  77.                    
  78.     }
  79.    
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement