File tree 3 files changed +66
-0
lines changed
19.Chapter_4_practice_set
3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class cwh_19_ch4_ps_pr_01 {
2
+ public static void main (String args []) {
3
+ int a = 10 ;
4
+ if (a = 11 ) {
5
+ system .out .println ("I am 11" );
6
+ }
7
+ else {
8
+ system .out .println ("I am not 11" );
9
+ }
10
+ // This program will through an error beacuse in if conditon
11
+ // a=11 is an assignment operator and we can't put assignment operator in if condition
12
+ // if we use a == 11 then will properly run the program
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+
3
+ public class cwh_19_ch4_ps_pr_02 {
4
+ public static void main (String args []) {
5
+ byte m1 , m2 , m3 ;
6
+ Scanner sc = new Scanner (System .in );
7
+ System .out .println ("Enter your marks in Physics" );
8
+ m1 = sc .nextByte ();
9
+
10
+ System .out .println ("Enter your marks in Chemistry" );
11
+ m2 = sc .nextByte ();
12
+
13
+ System .out .println ("Enter your marks in Mathematics" );
14
+ m3 = sc .nextByte ();
15
+ float avg = (m1 +m2 +m3 )/3.0f ;
16
+ System .out .println ("Your Overall percentage is: " + avg );
17
+ if (avg >=40 && m1 >=33 && m2 >=33 && m3 >=33 ){
18
+ System .out .println ("Congratulations, You have been promoted" );
19
+ }
20
+ else {
21
+ System .out .println ("Sorry, You have not been promoted! Please try again." );
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+
3
+ public class cwh_19_ch4_ps_pr_03 {
4
+ public static void main (String args []) {
5
+ Scanner sc = new Scanner (System .in );
6
+ System .out .println ("Enter your income in Lakhs per annum" );
7
+ float tax = 0 ;
8
+ float income = sc .nextFloat ();
9
+ if (income <=2.5 ){
10
+ tax = tax + 0 ;
11
+ }
12
+ else if (income >2.5f && income <= 5f ){
13
+ tax = tax + 0.05f * (income - 2.5f );
14
+ }
15
+ else if (income >5f && income <= 10.0f ){
16
+ tax = tax + 0.05f * (5.0f - 2.5f );
17
+ tax = tax + 0.2f * (income - 5f );
18
+ }
19
+ else if (income >10.0f ){
20
+ tax = tax + 0.05f * (5.0f - 2.5f );
21
+ tax = tax + 0.2f * (10.0f - 5f );
22
+ tax = tax + 0.3f * (income - 10.0f );
23
+ }
24
+
25
+ System .out .println ("The total tax paid by the employee is: " + tax );
26
+
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments