icabit

assignment add sub mul div

Jun 30th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. public class zzzz
  3. {
  4.  
  5.                 static BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
  6.         public static void main(String args []) throws IOException
  7.         {
  8.                         int x= 0;
  9.                         double y= 0;
  10.                         double z= 0;
  11.                         System.out.println("[1]Addition");
  12.                         System.out.println("[2]Substraction");
  13.                         System.out.println("[3]Multiplication");
  14.                         System.out.println("[4]Division");
  15.                         System.out.println("enter operation nuber: ");
  16.                         x=Integer.parseInt(in.readLine());
  17.                         System.out.println("enter Value1: ");
  18.                         z=Double.parseDouble(in.readLine());
  19.                         System.out.println("enter Value2: ");
  20.                         y=Double.parseDouble(in.readLine());
  21.                         if (x==1)
  22.                         {
  23.                             add(z,y);
  24.                         }
  25.                         else if (x==2)
  26.                         {
  27.                             sub(z,y);
  28.                         }
  29.                         else if (x==3)
  30.                         {
  31.                             mul(z,y);
  32.                         }
  33.                         else if (x==4)
  34.                         {
  35.                             div(z,y);                      
  36.                         }
  37.                         else{
  38.                             System.out.println("Invalid Operation number");
  39.                         }
  40.  
  41.         }
  42.         public static void add(double z,double y)
  43.         {
  44.             double n=z+y;
  45.             System.out.println("The Result is: "+n);
  46.         }
  47.         public static void sub(double z,double y)
  48.         {
  49.             double n=z-y;
  50.             System.out.println("The Result is: "+n);
  51.         }
  52.         public static void mul(double z,double y)
  53.         {
  54.             double n=z*y;
  55.             System.out.println("The Result is: "+n);
  56.         }
  57.         public static void div(double z,double y)
  58.         {
  59.             double n=z/y;
  60.             System.out.println("The Result is: "+n);
  61.         }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment