Simple Interest Calculation

Explanation:

  1. Input:
    • The program prompts the user to enter the principal amount, rate of interest, and time period in years.
  2. Switch Statement:
    • The switch statement checks the value of choice:
      • case 1: Calculates and displays the simple interest using the formula: Simple Interest=Principal×Rate×Time100\text{Simple Interest} = \frac{\text{Principal} \times \text{Rate} \times \text{Time}}{100}
      • case 2: Calculates the simple interest and then adds it to the principal to display the total amount after the specified time period.
      • default: Handles invalid choices by displaying an error message.
  3. Output:
    • Depending on the user’s choice, the program either displays the simple interest or the total amount after the interest is added to the principal.

Example Outputs:

Example 1: Simple Interest Calculation

Input:

  • Principal: 1000
  • Rate: 5
  • Time: 3
  • Choice: 1

Output:

Example 2: Total Amount Calculation

Input:

  • Principal: 2000
  • Rate: 4
  • Time: 2
  • Choice: 2

Output:

Example 3: Invalid Choice

Input:

  • Principal: 1500
  • Rate: 6
  • Time: 1
  • Choice: 3

Output: