Java All : Switch Based Selections

Exam Paper Problems

#### Difference Between Switch and If-Else #3918

( As In Exam - ICSE2014 )

Give two differences between switch statement and if-else statement.

Give two differences between switch statement and if-else statement.

#### if-else-if to switch-case #4061

( As In Exam - ICSE2018 )

Convert the following if else if construct into swit

Convert the following if else if construct into switch case
if( var==1)
System.out.println(“good”);
else if(var==2)
System.out.println(“better”);
else if(var==3)
System.out.println(“best”);
else
System.out.println(“invalid”);

#### Term Deposit Recurring Deposit Calculation #7439

( As In Exam - ICSE2014 )

Using the switch statement. write a menu driven program to calculate the matu

Using the switch statement. write a menu driven program to calculate the maturity amount of a Bank Deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept principal(P), rare of ¡interest(r) and time period in years(n). Calculate and output the maturity amount(A) receivable
using the formula

For option (ii) accept Monthly Installment (P), rate of interest(r) and time period in months (n). Calculate and output the maturity amount(A) receivable using the formula

For an incorrect option, an appropriate error message should be displayed.

Exam Paper Problems:3
×