-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFlow_filler.js
55 lines (49 loc) · 2.12 KB
/
Flow_filler.js
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
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static List<String> getVariableTypes() {
List<String> variableTypes = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("Enter the variable type (int, float, str, bool): ");
String variableType = scanner.nextLine();
if (variableType.equals("int") || variableType.equals("float") || variableType.equals("str") || variableType.equals("bool")) {
variableTypes.add(variableType);
} else {
System.out.println("Invalid variable type.");
continue;
}
System.out.println("Do you want to add another variable type? (y/n): ");
if (scanner.nextLine().equals("n")) {
break;
}
}
return variableTypes;
}
public static List<String> getVariableValues(List<String> variableTypes) {
List<String> variableValues = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
for (String variableType : variableTypes) {
System.out.printf("Enter the value for the %s variable: \n", variableType);
String variableValue = scanner.nextLine();
variableValues.add(variableValue);
}
return variableValues;
}
public static List<String> populateFlowchart(List<String> variableTypes, List<String> variableValues) {
List<String> flowchart = new ArrayList<>();
for (int i = 0; i < variableTypes.size(); i++) {
String variableType = variableTypes.get(i);
String variableValue = variableValues.get(i);
flowchart.add(variableType + ": " + variableValue);
}
return flowchart;
}
public static void main(String[] args) {
List<String> variableTypes = getVariableTypes();
List<String> variableValues = getVariableValues(variableTypes);
List<String> flowchart = populateFlowchart(variableTypes, variableValues);
System.out.println(flowchart);
}
}