-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuadraticFormula.java
92 lines (81 loc) · 2.98 KB
/
QuadraticFormula.java
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
//Name: Prabhav P.
//Period: 1A
import java.util.*;
import java.lang.Math;
public class QuadraticFormula
{
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
//challenge 1
System.out.println("Enter 2 numbers");
System.out.print("--> ");
double alpha = console.nextDouble();
System.out.print("--> ");
double beta = console.nextDouble();
double a = Math.max(alpha, beta);
System.out.println(a);
//challenge 2
System.out.print("Enter a number --> ");
double toCube = console.nextDouble();
toCube = Math.pow(toCube, 3);
System.out.println(toCube);
//challenge 3
System.out.println("Enter 2 numbers");
System.out.print("--> ");
double base = console.nextDouble();
System.out.print("--> ");
double exponent = console.nextDouble();
double c = Math.pow(base, exponent);
System.out.println(c);
//challenge 4
System.out.print("Enter a number --> ");
double num = console.nextDouble();
num = Math.rint(num);
System.out.println(num);
//challenge 5
System.out.print("Enter a number --> ");
double num2 = console.nextDouble();
num2 = Math.sqrt(num2);
System.out.println(num2);
//challenge 6
System.out.println("Enter 2 numbers");
System.out.print("--> ");
double sideA = console.nextDouble();
System.out.print("--> ");
double sideB = console.nextDouble();
sideA = Math.pow(sideA, 2);
sideB = Math.pow(sideB, 2);
double sideC = sideA + sideB;
sideC = Math.sqrt(sideC);
System.out.println(sideC);
//challenge 7
System.out.println("Enter 2 numbers");
System.out.print("--> ");
double gamma = console.nextDouble();
System.out.print("--> ");
double delta = console.nextDouble();
gamma = Math.abs(gamma);
delta = Math.abs(delta);
double f = Math.min(gamma, delta);
System.out.println(f);
//challenge 8
System.out.println("Enter 2 numbers");
System.out.print("--> ");
double cylinderRadius = console.nextDouble();
System.out.print("--> ");
double cylinderHeight = console.nextDouble();
double pi = Math.PI;
double r2 = Math.pow(cylinderRadius, 2);
double area = (2 * pi * cylinderRadius * cylinderHeight) + (2 * (pi * r2));
System.out.println(area);
//challenge 9
System.out.print("Enter a number --> ");
double sphereRadius = console.nextDouble();
double g = 4 / 3;
double pi2 = Math.PI;
double r3 = Math.pow(sphereRadius, 3);
double volume = g * pi2 * r3;
System.out.println(volume);
}
}