0% found this document useful (0 votes)
7 views3 pages

Revision - Decision Making

The document contains a revision worksheet with programming exercises focused on evaluating expressions, rewriting code using different control structures, and writing programs for various calculations. It includes tasks such as calculating taxi bills, daily wages, and discounts for a travel agency based on ticket amounts. Additionally, it provides examples of using loops, if-else statements, and switch statements in Java.

Uploaded by

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

Revision - Decision Making

The document contains a revision worksheet with programming exercises focused on evaluating expressions, rewriting code using different control structures, and writing programs for various calculations. It includes tasks such as calculating taxi bills, daily wages, and discounts for a travel agency based on ticket amounts. Additionally, it provides examples of using loops, if-else statements, and switch statements in Java.

Uploaded by

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

Revision

Worksheet 2
I. Evaluate the following expressions and write the output:
a) int p=12, q=10;
p+=((p+q)%10==0)?p++ + q++ : p-- - q--;
System.out.println ("p= "+p+"\nq= "+q);

b) int a=5,b=3;
if (++b>--a)
System.out.println(a++ + ++b);
else
System.out.println (a++ + --b);

c) Write the output: (i) char op='+'; (ii) char op='*';


switch (op)
{
case '+': System.out.println (10+30);
case '-': System.out.println (10-(-10)); break;
case '/': System.out.println(40/2); break;
default: System.out.println ("Incorrect choice");
}
II. Rewrite as directed:
a) Using while loop:
for (int a=10, b=20; a<=50; a+=5)
{
System.out.print(a);
System.out.println (b);
}

b) Using if else…if statements:


switch(ch)
{
case 'A': System.out.println (ch++); break;
case 'a': System.out.println (ch--); break;
default: System.out.println ("Invalid Input");
}

c) Using switch statement:


if(choice= =1 | choice= =2)
System.out.println ("Airtel");
else if(choice= =3 | choice= =4)
System.out.println ("Reliance");
else
System.out.println ("Tata Docomo");
Programs:-
1)W.A.P to calculate the taxi bill by accepting kilometres
travelled and to calculate the bill as per the following criteria.
km rate/km
first 5km 50
next 4 km 12
next 6 km 10
Above 15 km 8
2) WAP to calculate daily wages of sales man based on the
number of hours worked.
hours worked rate/hour
first 5 hrs Rs 100
next 6 hrs Rs 150
more than11 hrs Rs 200

3) WAP to perform the following functions using switch


statement based on the user’s choice.
1)To calculate Volume of cube(V=a3)
4
2)To calculate Volume of sphere(V=3πr3)
3)To calculate Volume of cuboid(V=lbh)

4)An XYZ travel agency gives the following discount based on


the ticket amount.
Travel amount(in Rs) Discount
Above 75,000 18%
55,001 to 75,000 16%
35,001 to 55,000 14%
Below 35,000 12%
WAP to accept ticket amount and display the amount to be paid
by the customer after availing the discount.

You might also like