Java Switch-Case Board Questions


  1. Using the switch-case statement, write a menu driven program to do the following: [15 MARKS-2019]

    (a) To generate and print Letters from A to Z and their Unicode

    Letters   Unicode
    A          65
    B          66
    .           .
    .           .
    Z          90
    
    (b) Display the following pattern using iteration (looping) statement:

    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    
  2. coming soon

  3. Write a menu driven program to display the pattern as per user’s choice.[15 MARKS-2018]

    Pattern 1

    ABCDE
    ABCD
    ABC
    AB
    A
    

    Pattern 2

    B
    LL
    UUU
    EEEE
    

    For an incorrect option, an appropriate error message should be displayed
  4. coming soon

  5. Using switch statement, write a menu driven program for the following: [15 MARKS-2017]

    (a) To find and display the sum of the series given below:

    S = x1 - x2 + x3 - x4 + x5 .......... - x20
    (where x = 2)

    (b) To display the following series:

    1, 11, 111, 1111, 11111

    For an incorrect option, an appropriate error message should be displayed.
  6. coming soon

  7. Using the switch statement, write a menu driven program for the following: [15 MARKS-2016]

    (i) To print the Floyd’s triangle [Given below]

    1
    2  3
    4  5  6
    7  8  9  10
    11 12 13 14 15
    
    (b) To display the following pattern:

    I
    I C
    I C S
    I C S E
    

    For an incorrect option, an appropriate error message should be displayed.
  8. coming soon

  9. Using switch statement, write a menu driven program to: [15 MARKS-2015]

    (i) To find and display all the factors of a number input by the user ( including 1 and excluding the number itself).

    Example:
    Sample Input : n = 15
    Sample Output : 1, 3, 5

    (ii) To find and display the factorial of a number input by the user (the factorial of a non-negative integer n, denoted by n!, is the product of all integers less than or equal to n.)

    Example:
    Sample Input : n = 5
    Sample Output : 5! = 1*2*3*4*5 = 120

    For an incorrect choice, an appropriate error message should be displayed.
  10. coming soon

  11. Using the switch statement, write a menu driven program to calculate the maturity amount of a Bank Deposit. The user is given the following options: [15 MARKS-2014]

    (i) Term Deposit
    (ii) Recurring Deposit

    For option 1, accept principal (P), rate of interest(r) and time period in years(n). Calculate and output the maturity amount(A) receivable using the formula:

    A = P[1 + r / 100]n

    For option 2, accept Monthly Installment (P), rate of interest (r) and time period in months (n). Calculate and output the maturity amount (A) receivable using the formula:

    A = P x n + P x (n(n+1) / 2) x r / 100 x 1 / 12

    For an incorrect option, an appropriate error message should be displayed.
  12. coming soon

  13. Using the switch statement, write a menu driven program: [15 MARKS-2013]

    (a) To check and display whether a number input by the user is a composite number or not.

    A number is said to be composite, if it has one or more than one factors excluding 1 and the number itself.

    Example: 4, 6, 8, 9...

    (b) To find the smallest digit of an integer that is input:

    Sample input: 6524

    Sample output: Smallest digit is 2

    For an incorrect choice, an appropriate error message should be displayed
  14. coming soon

  15. Using the switch statement, write a menu driven program to : [15 MARKS-2012]

    (a) Generate and display the first 10 terms of the Fibonacci series 0, 1, 1, 2, 3, 5…….

    The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

    (b) Find the sum of the digits of an integer that is input.

    Sample Input :
    15390

    Sample Output :
    Sum of digits = 18

    For an incorrect choice, an appropriate error message should be displayed.
  16. coming soon

  17. Write a menu driven program to perform the following tasks by using Switch case statement: [15 MARKS-2011]

    (a) To print the series:

    0, 3, 8, 15, 24, ............ to n terms.

    (value of 'n' is to be an input by the user)

    (b) To find the sum of the series:

    S = (1/2) + (3/4) + (5/6) + (7/8) + ........... + (19/20)
  18. coming soon

  19. Write a menu driven program to accept a number from the user and check whether it is a Prime number or an Automorphic number. [15 MARKS-2010]

    (a) Prime number: A number is said to be prime, if it is only divisible by 1 and itself.

    Example: 3,5,7,11

    (b) Automorphic number: Automorphic number is the number which is contained in the last digit(s) of its square.

    Example: 25 is an Automorphic number as its square is 625 and 25 is present as the last two digits.
  20. coming soon

  21. Write a menu driven class to accept a number from the user and check whether it is a Palindrome or a Perfect number. [15 MARKS-2008]

    (a) Palindrome number— A number is a Palindrome which when read in reverse order is same as read in the right order.

    Example : 11, 101, 151 etc.

    (b) Perfect number— A number is called Perfect if it is equal to the sum of its factors other than the number itself.

    Example : 6 = 1 + 2 + 3
  22. coming soon

  23. Using a switch statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message should be displayed. [15 MARKS-2007]

    (HINT : C = 5/9× (F – 32) and F = 1.8 × (C + 32) )
  24. coming soon