Guest User

Untitled

a guest
May 5th, 2015
292
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package prac1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner sca = new Scanner(System.in);
  8. double a, b, c, d;
  9. String s;
  10. System.out.println("What do you want to do: ");
  11. s = sca.next();
  12. if (s == "add"){
  13. System.out.println("Enter the first number: ");
  14. a = sca.nextDouble();
  15. System.out.println("Enter the second number: ");
  16. b = sca.nextDouble();
  17. c = a + b;
  18. System.out.println("The sum of " + a + " and " + b + " is " + c);
  19.  
  20.  
  21. }else if(s == "multiply" || s == "mul"){
  22. System.out.println("Enter the first number: ");
  23. a = sca.nextDouble();
  24. System.out.println("Enter the second number: ");
  25. b = sca.nextDouble();
  26. c = a * b;
  27. System.out.println("The product of " + a + " and " + b + " is " + c);
  28.  
  29. }else{
  30. return;
  31. }
  32.  
  33.  
  34.  
  35. }
  36.  
  37. }
RAW Paste Data