Challenge

Project

//Package :  arithmeticOperations

//Class : ArithmeticCalculator

package arithmeticOperations;

import java.io.FileNotFoundException; 
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.File; //importing the file class to store the console output
import java.io.PrintWriter; //importing the printwriter to print the value of console
import java.util.Scanner; //importing scanner class to take input from user

public class AritmeticCalculator { //creating a class named ArithmeticCalculator
public static void main(String[] args) throws IOException { //Initializing the main method
BinaryToDecimal bd = BinaryToDecimal(); //recalling the BinaryToDecimal class
DecimalToBinary db = DecimalToBinary(); //recalling the DecimalToBinary class

PrintWriter pw = new PrintWriter("CalculationHistory.txt"); //Initializing the file in which the console output is to be stored

int x = 1;
do { //Initializing the do while loop
try { //Exception handling using try and catch incase the user enters an invalid input
System.out.println("Operation's : ");
System.out.println("1- Addition");
System.out.println("2- Substraction");
System.out.println("3- Multiplication");
System.out.println("4- Division");
System.out.println("5- Exit");
System.out.println("Choose next option: ");
Scanner sc = new Scanner(System.in); //Intializing the scanner class
int choice = sc.nextInt(); //Taking input from the user

switch (choice) { //Creating switch cases
case 1:
System.out.println("Input two numbers : ");
System.out.println("Insert 1st number: ");
double numA = sc.nextDouble(); //Taking input from the user
System.out.println("Insert 2nd number: ");
double numB = sc.nextDouble(); //Taking input from the user
double a = numA + numB; 
pw.write((int) (numA + numB));
System.out.println("Sum =" + a + "is stored in memory");
bd.getDecimal(a);
db.getBinary(a);
break;
case 2:
System.out.println("Input two numbers : ");
System.out.println("Insert 1st number: ");
double numC = sc.nextDouble();
System.out.println("Insert 2nd number: ");
double numD = sc.nextDouble();
double d = numC - numD;
pw.write("The difference of the two numbers is" + (int) (numC - numD));
System.out.println("Difference =" + d + "is stored in memory");
bd.getDecimal(d);
db.getBinary(d);
break;
case 3:
System.out.println("Input two numbers : ");
System.out.println("Insert 1st number: ");
double numE = sc.nextDouble();
System.out.println("Insert 2nd number: ");
double numF = sc.nextDouble();
double m = numE * numF;
pw.write("The multiplication of the two numbers is" + (int) (numE * numF));
System.out.println("Multiplication =" + m + "is stored in memory");
bd.getDecimal(m);
db.getBinary(m);
break;
case 4:
System.out.println("Input two numbers : ");
System.out.println("Insert 1st number: ");
double numG = sc.nextDouble();
System.out.println("Insert 2nd number: ");
double numH = sc.nextDouble();
double di = numG / numH;
pw.write("The division of the two numbers is" + (int) (numG / numH));
System.out.println("Division =" + di + "is stored in memory");
bd.getDecimal(di);
db.getBinary(di);
break;
case 5:
System.out.println("Program Exited");
break;
}
} catch (Exception e) {
System.out.println("Wrong Input. Try Again.");
}
} while (x == 1);
pw.close();

}

private static DecimalToBinary DecimalToBinary() {
// TODO Auto-generated method stub
return null;
}

private static BinaryToDecimal BinaryToDecimal() {
// TODO Auto-generated method stub
return null;

}
}

Class BinaryToDecimal  : 

package arithmeticOperations;

public class BinaryToDecimal {
public int getDecimal(double a) {
int decimal =0;
int n = 0;
while(true) {
if(a == 0) {
break;
}
else {
double temp = a%10;
decimal += temp*Math.pow(2, n);
a = a/10;
n++;
}

}
return decimal;
}

}

Class DecimalToBinary   :

package arithmeticOperations;

public class DecimalToBinary {
public int getDecimal(int decimal) {
int binary =0;
int n = 0;
while(true) {
if(decimal == 0) {
break;
}
else {
int temp = decimal%10;
binary += temp*Math.pow(2, n);
decimal = decimal/10;
n++;
}

}
return binary;
}

public void getBinary(double a) {
// TODO Auto-generated method stub

}

}

//Package :  exponentialOperations

//Class :  exponentialCalculator 

package exponentialOperations;

import java.util.Scanner;

import arithmeticOperations.BinaryToDecimal;
import arithmeticOperations.DecimalToBinary;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.Math;

public class exponentialCalculator {
public static void main(String[] args) throws NumberFormatException, IOException {
BinaryToDecimal bd = BinaryToDecimal();
DecimalToBinary db = DecimalToBinary();
PrintWriter pw = new PrintWriter("CalculationHistory.txt");

int y = 1;
do {
try {
System.out.println("Operation's : ");
System.out.println("1- Raised to the pwer of -x to the y ");
System.out.println("2- Square root");
System.out.println("3- nth root");
System.out.println("4- Logaritmic value");
System.out.println("5- Natural Logaritmic value");
System.out.println("6- Exit");
System.out.println("Choose next option: ");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();

switch (choice) {
case 1:
System.out.println("Input two numbers : ");
System.out.println("Insert base: ");
double base = sc.nextDouble();
System.out.println("Insert exponent: ");
double exponent = sc.nextDouble();
long result = 1;
while (exponent != 0) {
result *= base;
--exponent;
}
pw.write("The base raise to exponent is " + (int) result);
System.out.println("base ^ exponent = " + result + "is stored in memory");
break;
case 2:
System.out.println("Input your numbers : ");
System.out.println("Insert the number: ");
double numCC = sc.nextDouble();
pw.write("The square root of the number is" + (int) Math.sqrt(numCC));
System.out.println("The square root of" + numCC + "is" + Math.sqrt(numCC) + "is stored in memory");
bd.getDecimal(numCC);
db.getBinary(numCC);
break;
case 3:
System.out.println("Input two numbers : ");
System.out.println("Put n ");
double numEE = sc.nextDouble();
System.out.println("nth root of the number: ");
double numFF = sc.nextDouble();
pw.write("The nth root of the number is" + (int) Math.pow(numFF, 1 / numEE));
System.out.println("nth root is =" + Math.pow(numFF, 1 / numEE) + "is stored in memory");
break;
case 4:
System.out.println("Input two numbers : ");
System.out.println("Insert the number whose logarithmic value is to be found ");
double numGG = sc.nextDouble();
pw.write("The logaritmic value is" + (int) Math.log10(numGG));
System.out.println(
"The logarithmic value of " + numGG + "is" + Math.log10(numGG) + "is stored in memory");
break;
case 5:
System.out.println("Input two numbers : ");
System.out.println("Insert the number whose logarithmic value is to be found ");
double numHH = sc.nextDouble();
pw.write("The natural logaritmic value is" + (int) Math.log(numHH));
System.out.println("The natural logarithmic value of " + numHH + "is" + Math.log(numHH));
break;
case 6:
System.out.println("Program Exited");
break;
}
} catch (Exception e) {
System.out.println("Wrong Input. Try Again.");
}
} while (y == 1);
pw.close();
}

private static DecimalToBinary DecimalToBinary() {
// TODO Auto-generated method stub
return null;
}

private static BinaryToDecimal BinaryToDecimal() {
// TODO Auto-generated method stub
return null;
}
}

Class BinaryToDecimal  :

package exponentialOperations;

public class BinaryToDecimal {
public int getDecimal(double a) {
int decimal = 0;
int n = 0;
while (true) {
if (a == 0) {
break;
} else {
double temp = a % 10;
decimal += temp * Math.pow(2, n);
a = a / 10;
n++;
}

}
return decimal;
}

}

Class DecimalToBinary   :

package exponentialOperations;

public class BinaryToDecimal {
public int getDecimal(double a) {
int decimal = 0;
int n = 0;
while (true) {
if (a == 0) {
break;
} else {
double temp = a % 10;
decimal += temp * Math.pow(2, n);
a = a / 10;
n++;
}

}
return decimal;
}

}

//Package :  trigonometricOperations

//Class :  TrigonometricCalculator

package trigonometricOperations;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Scanner;

import arithmeticOperations.BinaryToDecimal;
import arithmeticOperations.DecimalToBinary;

public class TrigonometricCalculator {
public static void main(String[] args) throws IOException {
BinaryToDecimal bd = BinaryToDecimal();
DecimalToBinary db = DecimalToBinary();
PrintWriter pw = new PrintWriter("CalculationHistory.txt");
int z = 1;
do {
try {
System.out.println("Operation's : ");
System.out.println("1- Calculate the Sine ");
System.out.println("2- Calculate the Inverse of Sine");
System.out.println("3- Calculate the Cosine");
System.out.println("4- Calculate the Inverse of Cosine");
System.out.println("5- Calculate the Tan");
System.out.println("6- Calculate the Inverse of Tan");
System.out.println("7- Exit");
System.out.println("Choose next option: ");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();

switch (choice) {
case 1:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only) to get Sine value: ");
double numAAA = sc.nextDouble();
double numBBB = Math.toRadians(numAAA);
double numS = Math.sin(numBBB);
pw.write("The sine value of the number is " + (int) numS);
System.out.println("The sine value of the number is " + numS);
break;

case 2:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only) to get Sine inverse value: ");
double numCCC = sc.nextDouble();
double numDDD = Math.toRadians(numCCC);
double numiS = Math.asin(numDDD);
pw.write("The sine inverse value of the number is " + (int) numiS);
System.out.println("The sine inverse value of the number is " + numiS);
break;
case 3:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only) to get Cosine value: ");
double numEEE = sc.nextDouble();
double numFFF = Math.toRadians(numEEE);
double numC = Math.cos(numFFF);
pw.write("The cosine value of the number is" + (int) numC);
System.out.println("The Cosine value of the number is " + numC);
break;
case 4:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only): ");
double numGGG = sc.nextDouble();
double numHHH = Math.toRadians(numGGG);
double numiC = Math.acos(numHHH);
pw.write("The cos inverse value of the number is" + (int) numiC);
System.out.println("The Cosine inverse value of the number is " + numiC);
break;
case 5:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only): ");
double numIII = sc.nextDouble();
double numJJJ = Math.toRadians(numIII);
double numT = Math.tan(numJJJ);
pw.write("The tan value is" + (int) numT);
System.out.println("The tan value of the number is " + numT);
break;
case 6:
System.out.println("Input the number : ");
System.out.println("Insert value (in numbers only): ");
double numKKK = sc.nextDouble();
double numLLL = Math.toRadians(numKKK);
double numiT = Math.atan(numLLL);
pw.write("The tan inverse value is" + (int) numiT);
System.out.println("The sine value of the number is " + numiT);
break;
case 7:
System.out.println("Program Exited");
break;
}
} catch (Exception e) {
System.out.println("Wrong Input. Try Again.");
}
} while (z == 1);
pw.close();
}

private static DecimalToBinary DecimalToBinary() {
// TODO Auto-generated method stub
return null;
}

private static BinaryToDecimal BinaryToDecimal() {
// TODO Auto-generated method stub
return null;
}
}

Class BinaryToDecimal  :

package trigonometricOperations;

public class BinaryToDecimal {
public int getDecimal(double a) {
int decimal = 0;
int n = 0;
while (true) {
if (a == 0) {
break;
} else {
double temp = a % 10;
decimal += temp * Math.pow(2, n);
a = a / 10;
n++;
}

}
return decimal;
}

}

Class DecimalToBinary   :

package trigonometricOperations;

public class DecimalToBinary {
public int getDecimal(int decimal) {
int binary = 0;
int n = 0;
while (true) {
if (decimal == 0) {
break;
} else {
int temp = decimal % 10;
binary += temp * Math.pow(2, n);
decimal = decimal / 10;
n++;
}

}
return binary;
}

public void getBinary(double a) {
// TODO Auto-generated method stub

}

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.