Skip to content

Commit c0a5767

Browse files
authored
Add files via upload
1 parent eaa08d2 commit c0a5767

1 file changed

Lines changed: 122 additions & 0 deletions

File tree

Calculator.java

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import java.util.Scanner;
2+
public class Calculator{
3+
public static void main(String[] args) {
4+
Scanner sc = new Scanner(System.in);
5+
System.out.println("Welcome to Fubu Calculator, May i please know your name:");
6+
String x = sc.nextLine();
7+
System.out.println("Hello!! " +x+ " Choose the Mathematical Operations that you want to use for your numbers:");
8+
System.out.println(" 1)Addition\n 2)Substraction\n 3)Multiplication\n 4)Division\n 5)Modulus\n 6)Square\n 7)Cube\n 8)Average\n 9)Percentage");
9+
int z = sc.nextInt();
10+
switch(z)
11+
{
12+
case 1:
13+
System.out.println("Addition");
14+
System.out.println("Enter integer one: ");
15+
int y = sc.nextInt();
16+
System.out.println("Enter integer two: ");
17+
int u = sc.nextInt();
18+
int sum = y+u;
19+
System.out.println("The Addition between " +y+ " and " +u+ " is: "+sum);
20+
break;
21+
22+
case 2:
23+
System.out.println("Substraction");
24+
System.out.println("Enter integer one: ");
25+
int r = sc.nextInt();
26+
System.out.println("Enter integer two: ");
27+
int a = sc.nextInt();
28+
int subs = r-a;
29+
System.out.println("The Substraction between " +r+ " and " +a+ " is: " + subs);
30+
break;
31+
32+
case 3:
33+
System.out.println("Multiplication");
34+
System.out.println("Enter integer one: ");
35+
int w = sc.nextInt();
36+
System.out.println("Enter integer two: ");
37+
int g = sc.nextInt();
38+
int f = w*g;
39+
System.out.println("The Multiplication between " +w+ " and " +g+ " is: "+f);
40+
break;
41+
42+
case 4:
43+
System.out.println("Division");
44+
System.out.println("Enter integer one: ");
45+
int v = sc.nextInt();
46+
System.out.println("Enter integer two: ");
47+
int s = sc.nextInt();
48+
double div =(double) v/s;
49+
System.out.println("The Division between" +v+ " and " +s+ " is: " +div);
50+
break;
51+
52+
case 5:
53+
System.out.println("Modulus");
54+
System.out.println("Enter integer one: ");
55+
int i = sc.nextInt();
56+
System.out.println("Enter integer two:");
57+
int m = sc.nextInt();
58+
float t = i%m;
59+
System.out.println("The Modulus between" +i+ " and " +m+ " is: " +t);
60+
break;
61+
62+
case 6:
63+
System.out.println("Square");
64+
System.out.println("Enter integer one: ");
65+
int q = sc.nextInt();
66+
int pi = q*q;
67+
System.out.println("The Square of " +q+ " is: " + pi);
68+
break;
69+
70+
case 7:
71+
System.out.println("Cubes");
72+
System.out.println("Enter a integer: ");
73+
int c = sc.nextInt();
74+
int cube = c*c*c;
75+
System.out.println("The Cube of " +c+ " is:" +cube);
76+
break;
77+
78+
case 8:
79+
System.out.println("Average");
80+
System.out.println("Enter integer one: ");
81+
int b = sc.nextInt();
82+
System.out.println("Enter integer two: ");
83+
int n = sc.nextInt();
84+
int Average = b+n;
85+
int yx = Average/2;
86+
System.out.println("The Average between " +b+ " and " +n+ " is: " + yx);
87+
break;
88+
89+
case 9:
90+
System.out.println("Percentage");
91+
System.out.println("Enter a number: ");
92+
int an = sc.nextInt();
93+
System.out.println("Choose the following in which you want the percentage in terms of");
94+
System.out.println(" 1)10% of your number\n 2)50% of your number\n 3)30% of your number");
95+
int xy = sc.nextInt();
96+
int yu = 10;
97+
int gh = 50;
98+
int hg = 30;
99+
int ui = 100;
100+
float per1 = (an * yu) / 100f;
101+
float per2 = (an * gh) / 100f;
102+
float per3 = (an * hg) / 100f;
103+
if(xy == 1){
104+
System.out.println("10% of " + an + " is: " + per1);
105+
}
106+
else if(xy == 2){
107+
System.out.println("50% of " + an + " is: " + per2);
108+
}
109+
else if(xy == 3){
110+
System.out.println("30% of " + an + " is: " + per3);
111+
}
112+
else{
113+
System.out.println("Error: Invalid option selected.");
114+
}
115+
break;
116+
117+
default:
118+
System.out.println("Hello Everyone,My name is Parth Rohilla,Hope you liked my Calculator.\nPlease do share it with your friends,i will be grateful if you did it,Thank you very much for reviewing it.");
119+
break;
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)