Computer Science, asked by vootkidsofficial55, 20 hours ago

What is the answer for the second sub Question
Please Answer me fast.
This is related to computer applications class 9 icse please dont spam anything in the answer​

Attachments:

Answers

Answered by laniban
0

Answer:

import java.util.Scanner; public class KboatSeriesMenu { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("1. Sum of the series"); System.out.println("2. Display series"); System.out.print("Enter your choice: "); int choice = in.nextInt(); switch (choice) { case 1: int sum = 0; for (int i = 1; i <= 20; i++) { int term = (int)Math.pow(2, i); if (i % 2 == 0) sum -= term; else sum += term; } System.out.println("Sum=" + sum); break; case 2: int term = 1; for (int i = 1; i <= 5; i++) { System.out.print(term + " "); term = term * 10 + 1; } break; default: System.out.println("Incorrect Choice"); break; } } }

Explanation:

see the image☝️☝️☝️

Attachments:
Similar questions