Project
import java.util.Scanner;
import java.util.*;
import java.lang.Math.*;
class Variables {
static int store1;
public static void main(String[] args) {
// static int store;
Scanner sc = new Scanner(System.in);
boolean condition = true;
while(condition)
{ System.out.println(
"1.+Plus"+ "\n" +
"2.-minus"+ "\n" +
"3.*multiply"+ "\n" +
"4./divide"+ "\n" +
"5.^power"+ "\n" +
"6.sqrt"+ "\n" +
"7.Nrt"+ "\n" +
"8.log"+ "\n" +
"9.natutallog"+ "\n" +
"10.sin"+ "\n" +
"11.inversesin"+ "\n" +
"12.cos"+ "\n" +
"13.inversecos"+ "\n" +
"14.tan"+ "\n" +
"15.inversetan"+ "\n" +
"16.store"+ "\n" +
"17.recall"+ "\n" +
"18.decimal to binary"+ "\n" +
"19.binary to decimal"+ "\n" +
"20.sip"
);
System.out.println("Please enter your cboice of operation");
int operation = sc.nextInt();
// long store1=0;
try {
switch(operation)
{
case 1:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Enter second number");
int y= sc.nextInt();
double sum=x+y;
System.out.println("Sum is ="+ sum);
}
break;
case 2:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Enter second number");
int y= sc.nextInt();
double minus=x-y;
System.out.println("miuns is ="+ minus);
}
break;
case 3:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Enter second number");
int y= sc.nextInt();
double multiply=x*y;
System.out.println("multiply is ="+ multiply);
}
break;
case 4:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Enter second number");
int y= sc.nextInt();
double divide=x/y;
System.out.println("divide is ="+ divide);
}
break;
case 5:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Enter power");
int y= sc.nextInt();
double power=Math.pow(x, y);
System.out.println("Power is "+ power);
}
break;
case 6:
{
System.out.println("Enter first number");
int x= sc.nextInt();
double sqrt=Math.sqrt(x);
System.out.println("Power is "+ sqrt);
}
break;
case 7:
{
System.out.println("Enter first number");
int x= sc.nextInt();
System.out.println("Power ");
int y= sc.nextInt();
double nthroot=Math.pow(x,1/y);
System.out.println("nthroot is ="+ nthroot);
}
break;
case 8:
{
System.out.println("Enter the num to find log");
int x=sc.nextInt();
System.out.println("Enter base to which log find");
int y= sc.nextInt();
double log= Math.log(x)/Math.log(y);
System.out.println("The log values is "+log);
}
break;
case 9:
{
System.out.println("Enter the num to find natural log");
int x=sc.nextInt();
double naturallog= Math.log(x);
System.out.println("The natural log values is " +naturallog);
}
break;
case 10:
{
System.out.println("Enter the num to find sin ");
int x=sc.nextInt();
double sin= Math.sin(x);
System.out.println("The sine value of "+ "x is "+sin);
}
break;
case 11:
{
System.out.println("Enter the num to find inversesin ");
int x=sc.nextInt();
double inversesin= Math.asin(x);
System.out.println("The inverse sine value of "+ "x is "+inversesin);
}
break;
case 12:
{
System.out.println("Enter the num to find cos ");
int x=sc.nextInt();
double cos= Math.cos(x);
System.out.println("The cos value of "+ "x is "+cos);
}
break;
case 13:
{
System.out.println("Enter the num to find inverse cos ");
int x=sc.nextInt();
double inversecos= Math.cos(x);
System.out.println("The inverse cos value of "+ "x is "+inversecos);
}
break;
case 14:
{
System.out.println("Enter the num to find tan ");
int x=sc.nextInt();
double tan= Math.tan(x);
System.out.println("The tan value of "+ "x is "+tan);
}
break;
case 15:
{
System.out.println("Enter the num to find inverse tan ");
int x=sc.nextInt();
double inversetan= Math.atan(x);
System.out.println("The inverse tan value of "+ "x is "+inversetan);
}
break;
case 16:
System.out.println("Enter the num to store ");
store1=sc.nextInt();
break;
case 17:
System.out.println("Your saved num is "+store1);
break;
case 18:
{
System.out.println("Enter the num to find binary ");
int x=sc.nextInt();
System.out.println("Thw binary value of x is"+Integer.toBinaryString(x));
}
break;
case 19:
{
System.out.println("Enter the num to convert to decimal ");
String binary=sc.next();
System.out.println("The decimal value is " +Integer.parseInt(binary,2));
}
break;
case 20:
{
System.out.println("Enter the amount to consolidate");
long x=sc.nextInt();
System.out.println("Enter period of months to achieve goal");
int y= sc.nextInt();
if(y<12) {
System.out.println("Sip to achieve montly is"+x/y);
System.out.println("Sip to achieve quaterly is"+x/(y/4));}
else if(y>=12)
{
int a= y/12;
int b= y%12;
int c= a+b;
System.out.println("Sip to achieve yearly is "+(x/c+x%c));
}
}
break;}
}
catch (Exception e)
{
System.out.println("Error occured");
}
}
}
}