Computer Science, asked by kapoorommeag123, 1 month ago

Write a menu-driven program to input a number,a character and choice to check as follows ----
Input a number ----
Press ‘d’ to check number is divisible by 4 or not.
Press ‘v’ to check character is vowel or not.
Enter choice -----

Answers

Answered by Equestriadash
8

The following co‎des have been written using Python.

while True:

   c = input("Enter a number/a character: ")

   print()

   print("Press 'd' to check if the number is divisible by 4 or not.")

   print("Press 'v' to check if the character is a vowel or not.")

   print()

   ch = input("Enter your choice: ")

   print()

   if ch in 'dD':

       if c.isalpha():

           print(c, "is not a number.")

       elif c.isnumeric():

           n = int(c)

           if n%4 == 0:

               print(n, "is divisible by 4.")

           else:

               print(n, "is not divisible by 4.")

   elif ch in 'vV':

       if c.isnumeric():

           print(c, "is not a character.")

       elif c.isalpha():

           if c in 'AEIOUaeiou':

               print(c, "is a vowel.")

           else:

               print(c, "is not a vowel.")

   print()

   nc = input("Would you like to go again? [Y/N]: ")

   print()

   if nc in 'Yy':

       continue

   else:

       break

Menu-driven programs are usually created using a \tt while loop. Once the character and choice have been entered, a conditional statement is pas‎sed to check what choice the user wants. Appropriate conditional statements are pas‎sed again to test if the character is suitable for the requested choice.

Similar questions