DevJourney · code I wrote while learning

README.md

1.8 KB

Insurance Policy Premium

Single File Programming Question Problem Statement Jacob recently turned 45 and wants to purchase an insurance policy. He visits an insurance company where the premium is calculated based on the customer's age and the type of insurance (Life or Health). The company uses a class named Insurance that collects input details, calculates the final premium with surcharges, and displays both base and final premiums. Help Jacob determine the final premium amount based on the company's rules. Rules: Age-Based Surcharge: If the age is above 50, add 20% of the base premium. If the age is between 30 and 50 (inclusive), add 10% of the base premium. If the age is below 30, no surcharge is added based on age. Insurance Type Surcharge: If the type is Life, add a flat ₹500. If the type is Health, add a flat ₹300. Input format : The first line of input consists of a String, representing the customer's name. The second line consists of an int, representing the age of the customer. The third line consists of a String, representing the type of insurance (Life or Health). The fourth line consists of a double, representing the base premium amount. Output format : The first line of output prints "Base Premium: " followed by a double representing the base premium. The second line of output prints "Final Premium: " followed by a double representing the final premium after applying all surcharges. Refer to the sample output for formatting specifications. Code constraints : The given testcases fall under the following constraints: 1 ≤ age ≤ 100 500.0 ≤ basePremium ≤ 100000.0 Type of insurance must be either "Life" or "Health" (case insensitive). Sample test cases : Input 1 : John Doe 45 Life 10000 Output 1 : 10000.0 11500.0 Input 2 : Alice 28 Health 8000 Output 2 : 8000.0 8300.0