Computer Science, asked by chrisvictor156, 10 months ago

Write a menu driven program to perform the following. (Use switch-case statement) :
(a) To print the series 0381524 n terms (value of 'n' is to be an input by the user).
(b) To find the sum of the series given below : [15] S = 1/2+ 3/4 + 5/6 + 7/8 .. 19/20.

Answers

Answered by devikamj5rv
12

Answer:

using switch case.

Explanation:

System.out.println("input a choice 'a' or 'b'");

char ch=(char) br.read;

//ch is the choice to be inputted.

switch(ch)

case'a':int n=Integer.parseInt(br.readLine());

//then print the series

break;

case'b':int s=0;

for(int n=1,d=2;n<=19,d<=20;n+=2,d+=2)

s+=n/d.0;

System.out.println("sum="+s);

Similar questions