-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFirstArray.java
More file actions
74 lines (57 loc) · 1.91 KB
/
FirstArray.java
File metadata and controls
74 lines (57 loc) · 1.91 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
package Online_Code_Samples.Week2;
import java.util.Scanner;
public class FirstArray {
private static int[] intArray;
private static Double[] doubleArray;
private static String[] stringArray;
private static final Scanner scanner = new Scanner(System.in);
private static void readIntegers(){
intArray = new int[3];
for(int i = 0; i < 3; i++){
System.out.print("Enter an integer: ");
int y = scanner.nextInt();
intArray[i] = y;
scanner.nextLine();
}
}
private static void readDoubles(){
doubleArray = new Double[3];
for(int i = 0; i < 3; i++){
System.out.print("Enter a double number: ");
double y = scanner.nextDouble();
doubleArray[i] = y;
scanner.nextLine();
}
}
private static void readStrings(){
stringArray = new String[3];
for(int i = 0; i < 3; i++){
System.out.print("Enter a String: ");
String y = scanner.nextLine();
stringArray[i] = y;
}
scanner.close();
}
public static void main(String[] args) {
readIntegers();
readDoubles();
readStrings();
System.out.println();
System.out.println();
System.out.println("+===============================================================+");
System.out.println("These are the integers entered");
for(int t: intArray){
System.out.println("Integer number: " + t);
}
System.out.println();
System.out.println("These are the doubles entered");
for(double t: doubleArray){
System.out.println("Double number: " + t);
}
System.out.println();
System.out.println("These are the Strings entered");
for(String t: stringArray){
System.out.println("String value: " + t);
}
}
}