Skip to content
Open
Binary file added Calculator.class
Binary file not shown.
50 changes: 50 additions & 0 deletions Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import java.util.Scanner;
public class Calculator
{ public static void main(String args[])
{


float a,b,res;
char choice,ch;
Scanner scan=new Scanner(System.in);

do{ System.out.println("1.Perform Subtraction");
System.out.println("2.Perform Addition");
System.out.println("3.Perform Multiplication");
System.out.println("4.Exit");
System.out.println("Enter your choice: ");
choice=scan.next().charAt(0);
switch(choice)
{ case '1': System.out.println("Enter two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
Subtract s =new Subtract(a,b);
s.getRes();
break;


case '2': System.out.println("Enter two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
res=a+b;
System.out.println("The result of addition is:" +res);
break;

case '3': System.out.println("Enter two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
Multiply m =new Multiply(a,b);
m.getResult();
break;

case '4':System.out.println("Exiting!!!");
System.exit(0);
break;

default:System.out.println("Entered wrong choice!!!");
break;
}
}while(choice!='4');
}

}
14 changes: 14 additions & 0 deletions Multiply.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Multiply
{
float a,b,res;
Multiply(float x,float y)
{
a=x;
b=y;
}
public void getResult()
{
res=a*b;
System.out.println("The result of multiplication is: "+res);
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
Sign your name in the list below

- [Rajula Vineet Reddy](http://github.com/rajula96reddy/) - IMT2014045
- [Samridhi Kundaliya ](https://github.com/sam1096) -MT2018101
14 changes: 14 additions & 0 deletions Subtract.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Subtract
{
float a,b,res;
Subtract(float x,float y)
{
a=x;
b=y;
}
public void getRes()
{
res=a-b;
System.out.println("The result of multiplication is: "+res);
}
}