Computer Science, asked by tanishapaul1340, 7 months ago

please solve this using SCANNER CLASS AND GIVE THE OUTPUT AS WELL.

If you spam i will report your answer as well as your question .​

Attachments:

idrisabbas07: ok

Answers

Answered by kingsmen99
2

import java.util.*;

class Series

{

public static void main(String args[])

{

int ch;

Scanner sc = new Scanner(System.in);

System.out.println("1. To display the sum of series");

System.out.println("2. To display the series");

System.out.println("Enter your choice");

ch = sc.nextInt();

switch(ch)

{

case 1:

int i, x = 2;

double s =0.0;

for(i = 1 ; i<= 20 ; i++)

{

if(i % 2 ! = 0)

s = s + Math.pow(x,i);

else

s = s - Math.pow(x,i);

}

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

break;

case 2:

int j, p = 1;

for( j = 1; j < = 4 ; j++)

{

p = p * 10 + 1 ;

System.out.println("The series : " +p);

}

break;

default:

System.out.println("Invalid choice!!");

}

}

}

HOPE IT MAY HELPS YOU..


tanishapaul1340: thank you
kingsmen99: Always Mention ❣
Similar questions