-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFor_loop3.java
More file actions
53 lines (49 loc) · 1.46 KB
/
Copy pathFor_loop3.java
File metadata and controls
53 lines (49 loc) · 1.46 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
package loop;
import java.util.Scanner;
public class For_loop3 {
public static void main(String[] args) {
int n,op,i;
String st = null;
Scanner objin = new Scanner(System.in);
do{
System.out.println("1. Loop 1");
System.out.println("1. Loop 2");
System.out.println("1. Loop 3");
System.out.println("1. Loop 4");
System.out.println("1. Loop 5");
System.out.print("Please Select One Option :");
op=objin.nextInt();
System.out.print("Input Number of Loop :");
n=objin.nextInt();
switch(op){
case 1:{
for(i=2;i<=n;i+=2){
System.out.print(i+" ");
}
}break;
case 2:{
for(i=2;i<=n;i+=3){
System.out.print(i+" ");
}
}break;
case 3:{
for(i=n;i>=n;i-=2){
System.out.print(i+" ");
}
}break;
case 4:{
for(i=n;i>=n;i-=3){
System.out.print(i+" ");
}
}break;
case 5:{
for(i=n;i>=n;i-=1){
System.out.print(i+" ");
}
}break;
}
System.out.print("\n Please Input Yes to Continue ....!");
st=objin.next();
}while(st.equals("yes"));
}
}