Java Question Set I – Conditional Statements in Java

3. Develop a program, that accepts a deposit amount and calculates the amount of interest earned on the deposited amount in a year. Where, the bank pays:

 

  • flat 4% for deposits of up to Rs.1000
  • flat 4.5% per year for deposits of up to Rs.5000
  • flat 5% for deposits of more than Rs.5000

Logic of the solution:

  1. Declare amount  and intst  as a double type as the user can have an amount of decimal points too.
  2. Print a message for the user using System.out.println  and ask the user for a amount
  3. Store the amount entered by the user into the variable amount
  4. Using if statement check if the amount is less than 1000 then
    • Interest will be 4%
  5. Otherwise, if it is between 1001 & 5000 then
    • Interest will be 4.5%
  6. Otherwise
    • Interest will be 5% flat
  7. While storing the interest calculated in the intst  variable that will be printed finally.

Output:

interest-program

Alternative logics that can be applied:

This question can also be solved using the switch conditional statement.

Continue to next page for another question.

0 Responses on Java Question Set I - Conditional Statements in Java|

Leave a Message

Your email address will not be published. Required fields are marked *

CommentLuv badge

Pin It on Pinterest