Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package firstprogram;
import java.io.*;
/**
*
* @author Neha Arora
*/
public class CalciUsr {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
CalciV2 cal=new CalciV2();
int cho;
do
{
System.out.println();
System.out.println("1. Addition");
System.out.println("2. Substraction");
System.out.println("3. Multiplication");
System.out.println("4. Division");
System.out.println("5. Percentage");
System.out.println("6. Exit");
System.out.print("Enter your choice: ");
cho=Integer.parseInt(br.readLine());
if(cho>=1 && cho<=5)
{
System.out.print("Enter the first input: ");
cal.n1=Double.parseDouble(br.readLine());
System.out.print("Enter the second input: ");
cal.n2=Double.parseDouble(br.readLine());
}
switch(cho)
{
case 1: //Addition
cal.add();
cal.display();
break;

case 2: //Substraction
cal.sub();
cal.display();
break;

case 3: //Multiplication
cal.mul();
cal.display();
break;

case 4: //Division
cal.div();
cal.display();
break;
case 5: //Percentage
cal.percentage();
cal.display();
break;

case 6: //Exit
System.out.println("You are leaving the calculator.");
break;

default:
System.out.println("Invalid Choice");
}
}while(cho!=6);
}
}

You might also like