Computer Science, asked by rajeshshettybn1974, 1 year ago

write a menu driven program to find and display the sum of the series in 0+3+8+15+24+n. using switch case statement

Answers

Answered by muralikrithi
24

Answer:

Explanation:

This is the java program written with whatever details is given in the question.

Hope it helps you.

 

import java.util.*;

class menu

{

public static void main(String args[])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter 1.To find the sum of series 0,3,8,15,24....n\n2.To Exit")

int ch=sc.nextInt();

switch(ch)

{

case 1:

System.out.println("Enter the nth term");

int n=sc.nextInt();

int sum=0;

for(int i=1;i<=n;i++)

{

sum=sum+((i*i)-1);

}

System.out.println("The sum of the series = "+sum);

break;

case 2:System.exit(0);

break;

default : System.out.println("Wrong entry");

break;

}

}

}

If it helped you please mark as brainliest

Answered by HeyiamStan
3

Answer:

thank you for marking my answer as brainliest in the second account in which i wrote the answer that is above

Similar questions