Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. /*
  2.  
  3.             *##..'^---^'..##*
  4.  
  5. */
  6.  
  7.  
  8.  
  9.  
  10.  
  11. import java.io.*;
  12.  
  13. import java.io.IOException;
  14.  
  15.  
  16.  
  17. public class Main {
  18.  
  19.    
  20.  
  21.     static BufferedReader waa = new BufferedReader(new InputStreamReader(System.in));
  22.     static double input1, input2;
  23.     static int z;  
  24.     static double output;
  25.    
  26.  
  27. public static void choices() throws IOException {
  28.  
  29.     System.out.println("Enter A Value 1-4\n1 - Addition\n2 - Subtraction\n3 - Multiplication\n4 - Division\nInput it Here: ");
  30.  
  31.     String Valz = waa.readLine();
  32.  
  33.     z = Integer.parseInt(Valz);
  34.  
  35. }
  36.  
  37.  
  38.  
  39. public static void Operation() throws IOException {
  40.  
  41.         System.out.print("Input 1st Number: ");
  42.  
  43.         String val1 = waa.readLine();
  44.  
  45.         input1 = Integer.parseInt(val1);
  46.  
  47. }
  48.  
  49.  
  50.  
  51. public static void Operation2() throws IOException {
  52.  
  53.         System.out.print("Input 2nd Number: ");
  54.  
  55.         String val2 = waa.readLine();
  56.  
  57.         input2 = Integer.parseInt(val2);
  58.  
  59. }
  60.  
  61. public static vod Ope1Ope2() throws IOException {
  62.         Operation();
  63.         Operation2();
  64. }
  65.  
  66.  
  67. public static void OperationOfNumbers() throws IOException {
  68.     switch(z) {
  69.     case 1:
  70.         Ope1Ope2();
  71.         output = input1 + input2;
  72.         display();
  73.         break;
  74.     case 2:
  75.         Ope1Ope2();
  76.         output = input1 - input2;
  77.         display();
  78.         break;
  79.     case 3:
  80.         Ope1Ope2();
  81.         output = input1 * input2;
  82.         display();
  83.         break;
  84.     case 4:
  85.         Ope1Ope2();
  86.         output = input1 / input2;
  87.         display();
  88.         break;
  89.     default:
  90.         System.out.println("Error: Please Try it Again");
  91.         do {
  92.         choices();
  93.         OperationOfNumbers();
  94.         }while(z != );
  95.         break;
  96.     }
  97. }
  98.  
  99. public static void display() throws IOException {
  100.     System.out.println("The Total Value: " + output);
  101. }
  102.  
  103.  
  104. public static void main(String args[]) throws IOException {
  105.  
  106.     choices();
  107.     OperationOfNumbers();
  108.  
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement