Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class zzzz
- {
- static BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
- public static void main(String args []) throws IOException
- {
- int x= 0;
- double y= 0;
- double z= 0;
- System.out.println("[1]Addition");
- System.out.println("[2]Substraction");
- System.out.println("[3]Multiplication");
- System.out.println("[4]Division");
- System.out.println("enter operation nuber: ");
- x=Integer.parseInt(in.readLine());
- System.out.println("enter Value1: ");
- z=Double.parseDouble(in.readLine());
- System.out.println("enter Value2: ");
- y=Double.parseDouble(in.readLine());
- if (x==1)
- {
- add(z,y);
- }
- else if (x==2)
- {
- sub(z,y);
- }
- else if (x==3)
- {
- mul(z,y);
- }
- else if (x==4)
- {
- div(z,y);
- }
- else{
- System.out.println("Invalid Operation number");
- }
- }
- public static void add(double z,double y)
- {
- double n=z+y;
- System.out.println("The Result is: "+n);
- }
- public static void sub(double z,double y)
- {
- double n=z-y;
- System.out.println("The Result is: "+n);
- }
- public static void mul(double z,double y)
- {
- double n=z*y;
- System.out.println("The Result is: "+n);
- }
- public static void div(double z,double y)
- {
- double n=z/y;
- System.out.println("The Result is: "+n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment