-
Notifications
You must be signed in to change notification settings - Fork 13
/
DemoLabellingWithBreak.java
62 lines (48 loc) · 1.87 KB
/
DemoLabellingWithBreak.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
import java.util.Scanner;
public class DemoLabellingWithBreak
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter two numbers: ");
// nextDouble() reads the next double from the keyboard
double first = in.nextDouble();
double second = in.nextDouble();
double result;
boolean t = true;
//System.out.print("Enter an operator (+, -, *, /): ");
//Char is a single alphabet where as String is a sequence of characters.
//char is a primitive data type
//char operator = in.next().charAt(0); //This will return the first char of the string
add:
{
sub:
{
mul:
{
divisionoperation:
{
// operator doesn't match any case constant (+, -, *, /)
defaul:
{
System.out.println(" I am done!!!");
if(t)
{
//System.out.println("I am terminating this program");
break mul;
}
}
result = first / second;
System.out.println("Number1 \t"+ first + "\t + "+ "/" + "\tNumber 2 \t"+ second + "=\t"+ result);
}
result = first * second;
System.out.println("Number1 \t"+ first + "\t + "+ "*" + "\tNumber 2 \t"+ second + "=\t"+ result);
}
result = first - second;
System.out.println("Number1 \t"+ first + "\t + "+ "-" + "\tNumber 2 \t"+ second + "=\t"+ result);
}
result = first + second;
System.out.println("Number1 \t"+ first + "\t + "+ "+" + "\tNumber 2 \t"+ second + "=\t"+ result);
}
}
}