Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.92 KB

practice-question-II.md

File metadata and controls

54 lines (43 loc) · 1.92 KB

Practice Questions

  1. Write a program that calculates the commission earned by a salesperson based on their sales amount and commission rate. Accept the sales amount form the user and calculate commission earned by sales person based on commission rate. Refer below table for different commission rates:

    Sales Amount Commission Rate %
    1 to 10000 3
    10001 to 25000 8
    25001 to 50000 15
    50001 to 100000 25
    100001 and above 35
        Sample Run 1:
        Enter Sales amount 24000
        Based on sales amount, commission eraned = 1920
    
        Sample Run 2:
        Enter Sales amount 300000
        Based on sales amount, commission eraned = 105000
    
  2. Write a program that checks if a given year is a leap year. Print "Leap Year" or "Not a Leap Year".

    Hint:
    A year is a leap year if it is divisible by 4 but not by 100, if it is divisible by 100, then it must be divisible by 400 to be a leap year.
    
    Sample Run 1:
    Enter year: 1996
    It's a leap year
    
    Sample Run 2:
    Enter year: 2000
    It's a leap year
    
    Sample Run 3:
    Enter year: 1900
    It's not a leap year
    
  3. Write a program that reads an integer and prints:

    • "Divisible by 2 and 3" if the number is divisible by both 2 and 3,
    • "Divisible by 2 but not 3" if the number is divisible by 2 but not 3,
    • "Divisible by 3 but not 2" if the number is divisible by 3 but not 2,
    • "Not divisible by 2 or 3" if the number is not divisible by either.
  4. Create a program that reads the current hour (0-23) and prints:

    • "Good Morning" for hours between 5 and 11,
    • "Good Afternoon" for hours between 12 and 17,
    • "Good Evening" for hours between 18 and 21,
    • "Good Night" for hours between 22 and 4.