-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAngle.java
More file actions
108 lines (104 loc) · 3.88 KB
/
Copy pathAngle.java
File metadata and controls
108 lines (104 loc) · 3.88 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
99
100
101
102
103
104
105
106
107
108
/**
* Mayank Prakash
* Std. 10'D'
* Roll no. 19
*/
import java.io.*;
class Angle
{
/**
* member variables
*/
private InputStreamReader ir;
private BufferedReader br;
/**
* default Constructor
*/
public Angle()
{
ir=new InputStreamReader(System.in);
br=new BufferedReader(ir);
}
/**
* display From Menu
*/
public void displaySubMenuFrom()
{
System.out.println("\f");
System.out.println(" !$$$$$$$$$$$$ #FROM MENU# $$$$$$$$$$$$!");
System.out.println(" !$ 1. Degrees $!");
System.out.println(" !$ 2. Radians $!");
System.out.println(" !$ 3. Back to Main Menu $!");
System.out.println(" !$. Enter your choice from 1 to 3 $!");
System.out.println(" !$$$$$$$$$$$$ #FROM MENU# $$$$$$$$$$$$!");
}
/**
* display To Menu
*/
public void displaySubMenuTo()
{
System.out.println("\f");
System.out.println(" !$$$$$$$$$$$$ #TO MENU# $$$$$$$$$$$$!");
System.out.println(" !$ 1. Degrees $!");
System.out.println(" !$ 2. Radians $!");
System.out.println(" !$. Enter your choice between 1 / 2 $!");
System.out.println(" !$$$$$$$$$$$$ #TO MENU# $$$$$$$$$$$$!");
}
/**
*Angle Convertor
*/
public void mainAngleConvertor()throws IOException
{
int frchoice, tochoice;
double angle;
String [ ]units= {" ","Degrees","Radians"};
do
{
displaySubMenuFrom();
frchoice = Integer.parseInt(br.readLine());
if(frchoice>=1&& frchoice<=2)
{
System.out.println("Enter Angle of your choice in "+units[frchoice]);
angle = Double.parseDouble(br.readLine());
displaySubMenuTo();
tochoice = Integer.parseInt(br.readLine());
}
else
{
System.out.println("Self-Destruction Mode Enabled: RETRY from Beginning");
for(int j=10; j>=1;j--)
{
System.out.print(j+"\t");
for(int i=1;i<=99900*10000;i++);
}
break;
}
switch(frchoice)
{
case 1:
switch(tochoice)
{
case 1: System.out.println("Angle of"+(angle)+units[frchoice]+"="+(angle*1)+units[tochoice]);
break;
case 2: System.out.println("Angle of"+(angle)+units[frchoice]+"="+(angle*22/7)/(90*2)+units[tochoice]);
break;
}
break;
case 2:
switch(tochoice)
{
case 1: System.out.println("Angle of"+(angle)+units[frchoice]+"="+(2*angle*90.0)/(22.0/7)+units[tochoice]);
break;
case 2: System.out.println("Angle of"+(angle)+units[frchoice]+"="+(angle*1)+units[tochoice]);
break;
}
break;
case 3: System.out.println("Back to Main Menu");
break;
default:System.out.println("INVALID OPTION");
}
System.out.println("Press any key to Continue Forward");
String x=br.readLine();
}while(frchoice!=3);
}
}