Conditional Statements

  1. if-else

    Question 1 of 2

    • Ask user for name and birth year. Calculate and display if he/she can vote in format: Ram, You are [not] eligible for voting. (Note: 18+ people can vote)
    • Ask user for num_1 and num_2. Display if num_1 is divisible by num_2 in format: 15 is [not] divisible by 3
    • Ask user for name, age and salary. Display if user is eligible for a loan in format: Ram, You are [not] eligible for loan. (Eligibility Rule: Age between 21 and 60, salary at least 30K)
    • Ask user for string and check if it's palindrome in format: "madam" is [not] a palindrome
    • Store customer balance in a variable. Ask user for amount to withdraw. If desired amount is less than total balance display, 123 withdrawn successfully. New Balance: 456 else display Insufficient balance. You only have 123 in your account
  2. if-else ladder

    Question 2 of 2

    • Ask user for marks and display grade in format: Your grade is A. (Rule: 90+ => A, 80-90 => B, 70-80 => C, 60-70 => D, below 60 F)
    • Ask user for birth year and display life stage in format: You are a teenager. (Rule: 0-12 => Child, 13-19 => Teenager, 20-59 => Adult, 60+ => Senior)
    • Ask user for three sides of a triangle and display type of triangle in format: This is an isosceles triangle. (Rule: All sides equal => Equilateral, Two sides equal => Isosceles, No sides equal => Scalene)
    • Ask user for two numbers and display the largest in format: The largest number is 5
    • Ask user for hour of the day (0-23) and display appropriate greeting in format: Good Morning. (Rule: 5-12 => Good Morning, 12-17 => Good Afternoon, 17-21 => Good Evening, 21-5 => Good Night, else invalid time)