Advertisement
ssss_reapz

Untitled

Feb 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package cal;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class cal {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9.  
  10. int numberone ;
  11. int numbertwo;
  12. int sum;
  13. int deduct;
  14. int mutiply;
  15. int divide;
  16. String choice;
  17.  
  18.  
  19.  
  20. Scanner read = new Scanner(System.in);
  21. System.out.println("Please enter a number");
  22. numberone = read.nextInt();
  23.  
  24. System.out.println("Please enter a number");
  25. numbertwo = read.nextInt();
  26.  
  27.  
  28. System.out.println("Please enter equation sign");
  29. choice = read.nextLine();
  30.  
  31.  
  32.  
  33. if (choice.equals("+"))
  34. {
  35. sum = numberone + numbertwo;
  36.  
  37. System.out.println(" "+ numberone +" + " + numbertwo+ " = "+ sum +" ");
  38. }
  39.  
  40. if (choice.equals("-"))
  41. {
  42. deduct = numberone - numbertwo;
  43. System.out.println(" "+ numberone +"- " + numbertwo+ " = "+ deduct +" ");
  44. }
  45.  
  46.  
  47. if (choice.equals("*"))
  48. {
  49. mutiply = numberone * numbertwo;
  50. System.out.println(" "+ numberone +" * " + numbertwo+ " = "+ mutiply +" ");
  51. }
  52.  
  53. if (choice.equals("/"))
  54.  
  55. {
  56. divide = numberone / numbertwo;
  57. System.out.println(" "+ numberone +" / " + numbertwo+ " = "+ divide +" ");
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement