Computer Science, asked by varun3632, 1 year ago

write Java programming fastly

Attachments:

varun3632: thanks

Answers

Answered by RAGHAVA12
1
import java.io.*; class Menu{ public static void main(String args[]) throws IOException{ InputStreamReader in = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(in); System.out.println("1. Series Sum"); System.out.println("2. Series"); System.out.print("Enter your choice: "); int choice = Integer.parseInt(br.readLine()); switch(choice){ case 1: int sum = 0; int x = 2; for(int i = 1; i <= 20; i++) sum += (int)Math.pow(x, i); System.out.println("Sum = " + sum); break; case 2: for(int i = 1; i <= 5; i++){ int t = ((int)Math.pow(10, i) - 1) / 9; System.out.print(t + "\t"); } break; default: System.out.println("Invalid choice!"); } } }
Similar questions