Computer Science, asked by dahiyadeepika2004, 2 months ago

Question 7:
(15)
Write a menu driven program to perform the following operations as per user's choice:
(i) To print the value of c=a+2ab, where a varies from 1.0 to 20.0 with increment of 2.0 and
b=3.0 is a constant.
(ii) To display the following pattern using for loop:
A
AB
ABC
ABCD
ABCDE
Display proper message for an invalid choice.
Ouestion 8.
1151​

Answers

Answered by meetvekariya277
1

Write the menu driven program

Answered by subhamagrawal7224
12

Answer:

import java.util.*;

class q7

{

   public static void main()

   {

       Scanner ob = new Scanner (System.in);

       System.out.println("Enter 1 for c=a^2+2ab");

       System.out.println("Enter 2 for pattern");

       int ch = ob.nextInt();

       switch (ch)

       {

           case 1:

           System.out.println("Enter a from 1.0 to 20.0");

           double a=ob.nextDouble();

           double b=3.0;

           double c;

           for(;a<=20.0;a=a+2.0)

           {

               c=a*a+2*a*b;

               System.out.println("Value of C = " +c);

           }

           break;

           case 2:

           int i,j;

           for(i=65;i<=69;i++)

           {

               for(j=65;j<=i;j++)

               {

                   System.out.print((char)j);

               }

               System.out.println();

           }

           break;

           default:

           System.out.println("Invalid Choice");

       }

   }

}

Explanation:

Similar questions