-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoop.java
More file actions
88 lines (81 loc) · 2.19 KB
/
Copy pathLoop.java
File metadata and controls
88 lines (81 loc) · 2.19 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.example.Loop;
import java.util.Scanner;
public class Loop {
public static Scanner scanner = new Scanner(System.in);
//Definite Finite
public void loopNumber(int x, int y){
if (x - y > 0){
while(x >= y){
System.out.println(x);
x--;
}
}
else if (x - y < 0){
while(x <= y){
System.out.println(x);
x++;
}
}
else if (x == y){
System.out.println(x);
}
}
//Definite Finite
public void exponentialSequence(double x, double y){
for(int z = 0; z <= 5; z++){
System.out.println(Math.pow(x, z) * y);
}
}
//Definite Finite
public void perfectSquare(int x){
int a = 0;
boolean b = false;
while (a*a < x){
a++;
if(x == a*a){
b = true;
break;
}
else{
continue;
}
}
if(b == true){
System.out.println(a);
}
else if(b == false){
System.out.println("Does not have a root");
}
}
//Definite Finite
public void greatestNumber(int x){
int a = 1;
int b = 0;
int c;
while (a <= x){
a++;
c = scanner.nextInt();
if (c >= b){
b = c;
}
}
System.out.println(b);
}
public static void main(String[]args){
System.out.println("Input two integers");
int a = scanner.nextInt();
int b = scanner.nextInt();
System.out.println("Input two doubles");
double c = scanner.nextDouble();
double d = scanner.nextDouble();
System.out.println("Input one integer");
int e = scanner.nextInt();
System.out.println("Input one integer");
int f = scanner.nextInt();
Loop runner = new Loop();
runner.loopNumber(a, b);
runner.exponentialSequence(c, d);
runner.perfectSquare(e);
runner.greatestNumber(f);
}
}