-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
64 lines (53 loc) · 1.67 KB
/
Copy pathMain.java
File metadata and controls
64 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.MfDevNet.www;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//practice1();
practice2();
}
public static void practice2() {
Scanner scanner = new Scanner(System.in);
String input;
do {
System.out.println("1)Average String Number");
System.out.println("2)Sum of String ");
System.out.print("Choose Number :");
int choose = scanner.nextInt();
System.out.println("For Exit Enter exit");
System.out.print("Enter Statement : ");
input = scanner.next();
System.out.println();
switch (choose) {
case 1:
int avg = input.length() / 2;
System.out.printf("Average is %d %n", avg);
break;
case 2:
int[] sum = new int[3];
sum[0] = input.length();
System.out.println(sum[0]);
sum[1] = (input.indexOf(input.charAt(0))) + (input.length());
System.out.println(sum[1]);
break;
default:
System.out.println("Enter Valid Number ");
break;
}
// System.out.println(input.equals("exit"));
} while (input != "EXIT");
}
public static void practice1() {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter count number : ");
int count = scanner.nextInt();
int[] arrayNumber = new int[count];
int sum = 0;
for (int i = 0; i < count; i++) {
System.out.print("Enter number : ");
arrayNumber[i] = scanner.nextInt();
// System.out.println();
sum += arrayNumber[i];
}
System.out.printf("Sum is %d", sum);
}
}