Challenge

Project

package simple;

import java.util.Scanner;

public class first {

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

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int b = 0, m = 1, s;
double c;

while (true) {
System.out.println("ENTER 1 FOR DO ADDITION\n ");
System.out.println("ENTER 2 FOR DO SUBSTRACTION\n ");
System.out.println("ENTER 3 FOR DO MULTIPLICATION\n ");
System.out.println("ENTER 4 FOR DO DIVISION \n");
System.out.println("ENTER 5 FOR DO ANY POWER \n");
System.out.println("ENTER 6 FOR DO SQUARE ROOT \n");
System.out.println("ENTER 7 FOR DO NTH ROOT \n");
System.out.println("ENTER 8 FOR DO logarithmic VALUE \n"); //this the inputs that user have to do
System.out.println("ENTER 9 FOR DO NAtural LOGARITHMICTURAL LOG \n");
System.out.println("ENTER 10 FOR DO SINE ANGLE \n");
System.out.println("ENTER 11 FOR DO INVERSE OF SINE \n");
System.out.println("ENTER 12FOR DO COSINE ANGLE \n");
System.out.println("ENTER 13 FOR DO INVERSE OF COSINE \n");
System.out.println("ENTER 14 FOR DO TAN ANGLE \n");
System.out.println("ENTER 15 FOR DO INVERSE OF TAN \n");
System.out.println("ENTER 16 FOR DO TO STORE VALUE \n");
System.out.println("ENTER 17 FOR DO RECALL \n");
System.out.println("ENTER 18 FOR DO DECIMAL TO BINARY NUMBER \n");
System.out.println("ENTER 19 FOR DO FOR BINARY TO DECIMAL NUMBER \n");
System.out.println("ENTER 20 FOR DO SYSTAMATIC INVESTMENT PLAN \n");

int input = sc.nextInt();
if (input == 1) {
System.out.println("How Many Numbers Do You Want To Add\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) { //this is the code of addition
System.out.println("enter your number" + z);
int a = sc.nextInt();
b = b + a;
}
System.out.println("Addition of numbers:- " + b);

System.out.println("do you want to do any other operation\n");

} else if (input == 2) {
System.out.println("How Many Numbers Do You Want To Subtract\n");
int n1 = sc.nextInt();
System.out.println("enter first number\n");
int no1 = sc.nextInt();
for (int z = 2; z <= n1; z++) { //this is the code of substraction
System.out.println("enter your number" + z);
int a = sc.nextInt();
no1 = no1 - a;
}
System.out.println("Substraction of numbers:- " + no1);
System.out.println("do you want to do any other operation\n");

} else if (input == 3) {
System.out.println("How Many Numbers Do You Want To Multiply\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) { //this is the code of multiplication
System.out.println("enter your number" + z);
int a = sc.nextInt();
m = m * a;
}
System.out.println("Multiplication of numbers:- " + m);
System.out.println("do you want to do any other operation\n");

} else if (input == 4) {
System.out.println("you can divide two numbers only.\n if you want to divide more then divide the ans\n ");
System.out.println("How Many Numbers Do You Want To Divide\n");
double n1 = sc.nextDouble();
System.out.println("enter your number 1");
double no1 = sc.nextDouble();
System.out.println("enter your number 2"); //this is the code of division
double no2 = sc.nextDouble();
c = no1 / no2;
for (int z = 3; z <= n1; z++) {
System.out.println("enter your number" + z);
double a = sc.nextDouble();
c = c / a;
}
System.out.println("Division of numbers:- " + c);
System.out.println("do you want to do any other operation\n");

} else if (input == 5) {
System.out.println("How Many Numbers power Do You Want\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
int p = 1;
System.out.println("enter your number" + z);
int a = sc.nextInt(); //this is the code of nth of mth power
System.out.println("which first power do you want of number" + a);
b = sc.nextInt();
System.out.println("which another power do you want of number" + a);
int k = sc.nextInt();
for (int y = 1; y <= b*k; y++) {
p = p * a;
}
System.out.println(b + "is first power and "+k +" is the another power of number " + a + " :- " + p);
}
System.out.println("do you want to do any other operation\n");

} else if (input == 6) {
System.out.println("How Many Numbers Do You Want Take Square Root\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your number" + z);
int a = sc.nextInt();

c = Math.sqrt(a);
System.out.println("square root of number:- " + c); //this is the code of square root
}
System.out.println("do you want to do any other operation\n");

} else if (input == 7) {
System.out.println("How Many Numbers Do You Want to Take Nth Root\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your number" + z);
int a = sc.nextInt();
System.out.println("Which Root Do You Want\n"); //this is the code of nth root
int p = sc.nextInt();
double d = 1.0 / p;
c = Math.pow(a, d);
System.out.println(p + "Th root of number:- "+a+" is " + c);
}
System.out.println("do you want to do any other operation\n");

} else if (input == 8) {
System.out.println("How Many Numbers Do You Want to Take logarithmic value\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your number" + z);
int a = sc.nextInt();
c = Math.log(a);
System.out.println(a + " number having log is :- " + c); //this is the code of logarithmic value
}
System.out.println("do you want to do any other operation\n");

} else if (input == 9) {
System.out.println("How Many Numbers Do You Want to Take natural logarithmic value\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your number" + z); //this is the code of natural logarithmic value
int a = sc.nextInt();
c = Math.log10(a);
System.out.println(a + " number having log is :- " + c);
}
System.out.println("do you want to do any other operation\n");
} else if (input == 10) {
System.out.println("How Many angles Do You Want to Take sine angle\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your angle" + z); //this is the code of sine angle
double a = sc.nextInt();
double x = Math.toRadians(a);
c = Math.sin(x);
System.out.println(a + " number having sine angle :- " + c);
}
System.out.println("do you want to do any other operation\n");

} else if (input == 11) {
System.out.println("Enter number how many do you want to take sine inverse\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your value" + z);
double w = sc.nextDouble();

System.out.println(Math.toDegrees(Math.asin(w))); //this is the code of inverse sine angle
}
System.out.println("do you want to do any other operation\n");

} else if (input == 12) {
System.out.println("How Many angles Do You Want to Take cosine angle\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your angle" + z);
int a = sc.nextInt();
double x = Math.toRadians(a);
c = Math.cos(x);
System.out.println(a + " number having cosine angle :- " + c); //this is the code of cosine angle
}
System.out.println("do you want to do any other operation\n");

} else if (input == 13) {
System.out.println("Enter number how many do you want to take cosine inverse\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your value" + z);
double w = sc.nextDouble();

System.out.println(Math.toDegrees(Math.asin(w))); //this is the code of inverse cosine angle
}
System.out.println("do you want to do any other operation\n");

} else if (input == 14) {
System.out.println("How Many angles Do You Want to Take tan angle\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your angle" + z); //this is the code of tangent angle
int a = sc.nextInt();
double x = Math.toRadians(a);
c = Math.tan(x);
System.out.println(a + " number having tan angle :- " + c);
}
System.out.println("do you want to do any other operation\n");

} else if (input == 15) {
System.out.println("Enter number do you want to take tan inverse\n");
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your value" + z);
double w = sc.nextInt(); //this is the code of inverse tangent

System.out.println(Math.toDegrees(Math.atan(w)));
}
System.out.println("do you want to do any other operation\n");

} else if (input == 16) {

System.out.println("enter your value");
s = sc.nextInt();

System.out.println(s + " is store in variable s");

System.out.println("do you want to do any other operation\n"); //this is the code of store the value

} else if (input == 17) {

int e=1;
// recall();
System.out.println(e);
if(e==5)
break;
// recall();
System.out.println("do you want to do any other operation\n");
} else if (input == 18) {
int a;
String b1;
System.out.println("how many binary number do you want \n"); //this is the code of integer to the binary number
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {
System.out.println("enter your numer" + z);
int w = sc.nextInt();
b1 = Integer.toBinaryString(w);
System.out.println(b1);
}
System.out.println("do you want to do any other operation\n");

} else if (input == 19) {
System.out.println("how many binary number do you want \n"); //this is the code of integer to the binary number
int n1 = sc.nextInt();
for (int z = 1; z <= n1; z++) {

System.out.println("enter string :-"+z);
int p=sc.nextInt();

System.out.println("Decimal of 1010 is: "+decimal(p));

}
System.out.println("do you want to do any other operation\n"); //this is the code of systematic investment plan
} else if (input == 20) {
System.out.println("enter your yearly interest ");
double n1 = sc.nextDouble();
double pd = n1 / 12;
System.out.println("enter your monthly ammount");
double am = sc.nextDouble();
double am2=am;
System.out.println("your interest will increase by 0.1% per month");
System.out.println("enter how many year do you want to store");
int year = sc.nextInt();
System.out.println("enter how many month do you want to store");
int month = sc.nextInt();
double inte;
for(double j=0.1,g=1; j<=year * 12 + month&&g<=year * 12 + month;j=j+0.1,g++) {
inte = pd + j;
am = am + am*inte/100;

}


System.out.println("your amount is " + am2 + " and after " + year + " year and " + month+ " months the amount is" + am);
}
}
System.out.println("do you want to do any other operation\n");
}
}

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.