0% found this document useful (0 votes)
3K views7 pages

Slab Based Programs-1

Uploaded by

deepa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views7 pages

Slab Based Programs-1

Uploaded by

deepa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

WAP to calculate the tax the person has to pay, based on

their income.

 If the income is less than 2,50,000 there is no tax.


 If the income is above 2,50,000 but below 5,00,000 :
the tax will be 5% of the income above 2,50,000.
 If the income is above 5,00,000 but less than
10,00,000 : their tax will be 10% of the income above
500,000 + tax for the slab 250,001 to 500,000
 Lastly, If the income is above 10,00,000 : their tax will
be 15% of the income above 10,00,000 + tax for the
slab 5,00,001 to 10,00,000 + tax for the slab 250,001
to 500,000

WAP program to input electricity unit charges and calculate


total electricity bill according to the given condition:

 For first 50 units Rs. 0.50/unit


 For next 100 units Rs. 0.75/unit
 For next 100 units Rs. 1.20/unit
 For unit above 250 Rs. 1.50/unit An additional
surcharge of 20% is added to the bill

3. Given below is a hypothetical table showing rates of Income Tax for male citizens
below the age of 65 years:

Taxable Income (TI) in Income Tax in

Does not exceed 1,60,000 Nil

Is greater than 1,60,000 and less than or equal to 5,00,000 ( TI – 1,60,000 ) * 10%

Is greater than 5,00,000 and less than or equal to 8,00,000 [ (TI - 5,00,000 ) *20% ] + 34,000

Is greater than 8,00,000 [ (TI - 8,00,000 ) *30% ] + 94,000

 Write a program to input the age, gender (male or female) and Taxable
Income of a person.If the age is more than 65 years or the gender is female,
display “wrong category*.
If the age is less than or equal to 65 years and the gender is male, compute
and display the Income Tax payable as per the table given above.

4. Define a class called Library with the following description:


Instance variables/data members:
Int acc_num – stores the accession number of the book
String title – stores the title of the book stores the name of the author
Member Methods:
(i) void input() – To input and store the accession number, title and author.
(ii)void compute – To accept the number of days late, calculate and display and fine
charged at the rate of Rs.2 per day.
(iii) void display() To display the details in the following format:
Accession Number Title Author
Write a main method to create an object of the class and call the above member
methods.

5.

6.

7.

Find the Output - While Loop based


int x = 1, i = 2;
while(++i <= 5)
{
x *= i;
}
System.out.println(x);

Output: 60

int i = 1;
int d = 5;
while(i <= 5)
{
d = d * 2;
System.out.println(d);
i++;
}
Output
10
20
40
80

160

3. int m = 5, n = 10;
while (n >= 1)
{
System.out.println(m * n);
n--;
}

Output: 50
45
40
35
30
25
20
15
10
5

4. int x = 1, s = 0;
while (x <= 7)
{
s += x;
x += 2;
}
System.out.println(s);

Output: 16

5. int x = 5;
int y = 75;
while (x <= y)
{
y = y/x;
System.out.println(y);
}

Output: 15
3

6. int x = 10, c = 20;


while(c >= 10)
{
x++;
c = c - 2;
System.out.println(c);
}
Output:
18
16
14
12
10
8

7. int p = 200;
while(true)
{
if(p < 100)
break;
p = p - 20;
}
System.out.println(p);

Output: 80

8. int x = 0;
while(x++ < 20)
{
if(x % 2 == 0)
System.out.println("Simply");
else if (x == 9)
break;
else
continue;
}

Output: Simply
Simply
Simply
Simply

Find the Output - For Loop based


1. for(int i = 0; i <= 5; i++ )
{
System.out.println("i = " + i );
}

Output: i = 0
i = 1
i = 2
i = 3
i = 4
i = 5

2. for (int i = 0; i < 10; i++) {


if (i == 4) {
break;
}
System.out.println(i);
}
output

0
1
2
3

3. for (int i = 0; i < 10; i++) {


if (i == 4) {
continue;
}
System.out.println(i);
}
Output
0
1
2
3
5
6
7
8
9

4. int i = 0;
for(;i <= 5; i++ )
{
System.out.println("i = " + i );
}
System.out.println("i after the loop = " + i );
output
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
i after the loop = 6

5. for(int i = 10; i <= 5; i-- )


{
System.out.println("i = " + i );
}
output
6. int number = 5;
int factorial = 1;

for(int i = 2; i <= number; i++ )


{
factorial *= factorial;
}

System.out.println("Factorial of 5 is " + factorial);


output
Factorial of 5 is 1

7. int number = 5;
int factorial = 1;

for(int i = 2; i <= number; i++ )


{
factorial *= number;
}

System.out.println("Factorial of 5 is " + factorial);


output
Factorial of 5 is 625

8. int a, b;
for(a = 1, b = 4; a < b; a++, b--)
{
System.out.println("a = " + a);
System.out.println("b = " + b);
}
Output
a = 1
b = 4
a = 2
b = 3

9. int a, b;
for (a = 6, b = 4; a <= 24; a = a + 6)
{
if (a % b == 0)
break;
}
System.out.println(a);
Output
12
10. int i;
for ( i = 5 ; i > 10; i++ )
System.out.println( i );
System.out.println( i * 4 );
output
20

11. int i;
for( i=5 ; i>=1 ;i--)
{
if(i%2 ==1)
continue;
System.out.print( i+ "");
}
output
42

12. for(int m = 5; m <= 20; m += 5)


{
System.out.println("Hello!");
if(m % 3 == 0)
break;
else if(m % 5 == 0)
continue;
System.out.println(m);

}
output

Hello!
Hello!
Hello!

You might also like