-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh04_20_Practice7.java
More file actions
132 lines (114 loc) · 4.3 KB
/
Ch04_20_Practice7.java
File metadata and controls
132 lines (114 loc) · 4.3 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import java.lang.classfile.instruction.SwitchCase;
import java.util.Scanner;
public class Ch04_20_Practice7 {
public static void main(String[] args) {
// Output finder
int a = 10;
if (a==11){
System.out.println("I am 11");
}
else {
System.out.println("I am not 11");
} //Predicted output is I am not 11
System.out.println(" ");
//Student Result
Scanner input = new Scanner(System.in);
System.out.println("Enter the following subjects marks: ");
System.out.print("Physics:");
int P = input.nextInt();
System.out.print("Chemistry:");
int C = input.nextInt();
System.out.print("Maths:");
int M = input.nextInt();
float percentage = (float)(P+C+M)/(300)*100;
System.out.printf("Your Percentage is %f\n" , percentage);
if (percentage>=40.0f && P>=33 && C>=33 && M>=33){
System.out.println("You Passed");
}
else {
System.out.println("Failed! Better luck next time");
}
System.out.println(" ");
// Tax Calculator , Income > 2.5L to 5L - 5% , 5-10 - 20% , above 10>30%
System.out.print("Enter your Income(Lakhs): ");
float Income = input.nextFloat();
if (Income >= 10.0f){
System.out.println("Income Tax - 30%");
float Tax = (0.3f*Income);
System.out.printf("Tax to be paid is: %f\n" , Tax);
System.out.println("Amount in hand: " + (Income - Tax));
}
else if (Income >= 5.0f && Income<10.0f){
System.out.println("Income Tax - 20%");
float Tax = (0.2f*Income);
System.out.printf("Tax to be paid is: %f\n" , Tax);
System.out.println("Amount in hand: " + (Income - Tax));
}
else if(Income >=2.5f && Income<5.0f){
System.out.println("Income Tax - 5%");
float Tax = (0.05f*Income);
System.out.printf("Tax to be paid is: %f\n" , Tax);
System.out.println("Amount in hand: " + (Income - Tax));
}
else {
System.out.println("Income Tax - 3%");float Tax = (0.03f*Income);
System.out.printf("Tax to be paid is: %f\n" , Tax);
System.out.println("Amount in hand: " + (Income - Tax));
}
System.out.println(" ");
//Weekday teller
System.out.print("Enter the serial no. of day: ");
int Day = input.nextInt();
switch (Day){
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Enter valid integer between 1 - 7");
}
System.out.println(" ");
// Leap Year finder
System.out.print("Enter the year you are riding right now: ");
int Year = input.nextInt();
if (Year%4 == 0){
System.out.println("You are in Leap Year");
}
else{
System.out.println("This is a normal year ! No extra Day");
}
System.out.println(" ");
//Type of Website , .com - commercial , .org - organisation , .in - indian
Scanner ws = new Scanner(System.in);
System.out.print("Search your website: ");
String website = ws.nextLine();
if (website.indexOf(".com")>0){
System.out.println("This is a commercial Website");
} else if (website.indexOf(".org")>0) {
System.out.println("This is an organisation website");
} else if (website.indexOf(".in")>0) {
System.out.println("This is an Indian Website");
}
else{
System.out.println("Enter a valid URL");
}
System.out.println("*******");
}
}