Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package simplecalc;
- /**
- *
- * @author Jimmy
- */
- import java.util.Scanner;
- public class SimpleCalc {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner user_input = new Scanner(System.in);
- String whatMath;
- System.out.print("Multiply, divide, add or subtract?");
- whatMath = user_input.next();
- System.out.println("You chose to " + "["+whatMath+"]");
- int numberOne;
- System.out.print("Enter any number...");
- numberOne = user_input.nextInt();
- System.out.print("You entered: " + "["+numberOne+"]" );
- int numberTwo;
- System.out.print("Enter another number...");
- numberTwo = user_input.nextInt();
- System.out.println("You also entered: " + "["+numberTwo+"]");
- if("multiply".equalsIgnoreCase(whatMath)){
- int multiSum = numberOne * numberTwo;
- System.out.println("So " + numberOne + " * " + numberTwo);
- System.out.println("The sum of your problem is: " + multiSum);
- }else if("divide".equalsIgnoreCase(whatMath)){
- int divideSum = numberOne / numberTwo;
- System.out.println("So " + numberOne + " / " + numberTwo);
- System.out.println("The sum of your problem is: " + divideSum);
- }else if("add".equalsIgnoreCase(whatMath)){
- int addSum = numberOne + numberTwo;
- System.out.println("So " + numberOne + " + " + numberTwo);
- System.out.println("The sum of your problem is: " + addSum);
- }else if("subtract".equalsIgnoreCase(whatMath)){
- int minusSum = numberOne - numberTwo;
- System.out.println("So " + numberOne + " - " + numberTwo);
- System.out.println("The sum of your problem is: " + minusSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement