h4344

Math1

Sep 12th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class h4Math {
  4.  
  5. public static void main(String []args) {
  6.  
  7.  
  8. Scanner scan = new Scanner(System.in);
  9. double answer1 = 0;
  10. double answer2 = 0;
  11. double answer3 = 0;
  12. int Right = 0;
  13. int Wrong = 0;
  14.  
  15.  
  16.  
  17. System.out.println("-----------------");
  18. System.out.println("Created By h4344");
  19. System.out.println("-----------------");
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. //Problem 1
  27. double fnum1 = 0, snum1 = 0;
  28. System.out.println("What 2 numbers = 4?");
  29. System.out.println("Enter First Number: ");
  30. fnum1 = scan.nextDouble();
  31. System.out.println("Enter Second Number: ");
  32. snum1 = scan.nextDouble();
  33. answer1 = fnum1 + snum1;
  34.  
  35.  
  36. if(answer1 == 4) {
  37. System.out.println(Right + 1);
  38. }
  39.  
  40. else{
  41. System.out.println(Wrong + 1);
  42. }
  43.  
  44. //Problem 2
  45. double fnum2 = 0, snum2 = 0;
  46. System.out.println("What 2 numbers = 11?");
  47. System.out.println("Enter First Number: ");
  48. fnum2 = scan.nextDouble();
  49. System.out.println("Enter Second Number: ");
  50. snum2 = scan.nextDouble();
  51. answer2 = fnum2 + snum2;
  52.  
  53.  
  54. if(answer2 == 11) {
  55. System.out.println(Right + 1);
  56. }
  57.  
  58. else{
  59. System.out.println(Wrong + 1);
  60. }
  61.  
  62. //Problem 3
  63. double fnum3 = 0, snum3 = 0;
  64. System.out.println("What 2 numbers = 24?");
  65. System.out.println("Enter First Number: ");
  66. fnum3 = scan.nextDouble();
  67. System.out.println("Enter Second Number: ");
  68. snum3 = scan.nextDouble();
  69. answer3 = fnum3 + snum3;
  70.  
  71.  
  72. if(answer3 == 24) {
  73. System.out.println(Right + 1);
  74. }
  75.  
  76. else{
  77. System.out.println(Wrong + 1);
  78. }
  79.  
  80. if(Right > Wrong);
  81. System.out.println(Right + " Congrats You Passed!");
  82.  
  83. if(Wrong > Right);
  84. System.out.println(Wrong + " Sorry You Did Not Pass");
  85.  
  86. if(Right == Wrong);
  87. System.out.println("Same Amount Right as Wrong.");
  88. }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment