-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectCalculator.java
More file actions
98 lines (94 loc) · 2.62 KB
/
Copy pathProjectCalculator.java
File metadata and controls
98 lines (94 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* 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 assignment_10528808;
/**
*
* @author Mawutor
*/
import java.util.Scanner;
public class ProjectCalculator
{
public static double add()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the numbers to compute respectively");
double n=input.nextDouble();
double v=input.nextDouble();
double b=n+v;
System.out.printf("%g+%g=%g",n,v,b);
return b;
}
public static double subs()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the numbers to compute respectively");
double n=input.nextDouble();
double v=input.nextDouble();
double b=n-v;
System.out.printf("%g-%g=%g",n,v,b);
return b;
}
public static double div()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the numbers to compute respectively");
double n=input.nextDouble();
double v=input.nextDouble();
double b=n/v;
System.out.printf("%g/%g=%g",n,v,b);
return b;
}
public static double mul()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the numbers to compute respectively");
double n=input.nextDouble();
double v=input.nextDouble();
double b=n*v;
System.out.printf("%g*%g=%g",n,v,b);
return b;
}
public static double exp()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the numbers to compute respectively");
int d=input.nextInt();
int v=input.nextInt();
int b= d^v;
System.out.printf("%d^%d=%d",d,v,b);
return b;
}
public static void main(String[] arg)
{
int e=0;
while(e==0)
{
Scanner input = new Scanner(System.in);
System.out.printf("1)Addition%n2)Subtraction3)Division%n4)Multiplication%n5)Exponential");
System.out.println("Enter an option");
int option=input.nextInt();
if(option==1)
{
add();
}
else if(option==2)
{
subs();
}
else if(option==3)
{
div();
}
else if(option==4)
{
mul();
}
else if(option==5)
{
exp();
}
}
}}