Question: Program: Data visualization (Java): Please help me fix the issues with my current code to match up with the expected Input: Current Code import java.util.Scanner;
Program: Data visualization (Java): Please help me fix the issues with my current code to match up with the expected Input:
Current Code
import java.util.Scanner; import java.util.ArrayList;
public class DataVisualizer { public static void main(String[] args) { /* Type your code here. */ Scanner input = new Scanner(System.in);
//1
System.out.println("Enter a title for the data: ");
String title = input.nextLine();
System.out.println("You entered: "+title);
//2
System.out.println("Enter the column 1 header: ");
String header1 = input.nextLine();
System.out.println("You entered: "+header1);
System.out.println("Enter the column 2 header: ");
String header2 = input.nextLine();
System.out.println("You entered: "+header2);
//3.
ArrayList
ArrayList
while(true){
System.out.println("Enter a data point (-1 to stop input): ");
String point = input.nextLine();
if("-1".equalsIgnoreCase(point.trim()))
break;
int index = point.indexOf(',');
// if there is a comma in input
if(index != -1){
String pointStr = point.substring(0, index).trim();
String str = point.substring(index+1).trim();
// if only one comma is in input
if(str.indexOf(',') == -1){
try{
int x = Integer.parseInt(str);
System.out.println("Data string: "+pointStr);
System.out.println("Data integer: "+x);
// adding in list
strList.add(pointStr);
intList.add(x);
}catch(Exception e){
System.out.println("Comma not followed by an integer");
}
}else{
System.out.println("To many commas in input");
}
}else{
System.out.println("No comma in string");
}
}
System.out.println();
System.out.println(title);
System.out.println(header1+"\t|\t"+header2);
for(int i=0; i System.out.println(strList.get(i)+"\t|\t"+intList.get(i)); } return; } } My Input VS Expected Input Thank you in advance for your help in solving where I am missing steps. 

![java.util.Scanner; import java.util.ArrayList; public class DataVisualizer { public static void main(String[] args)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45ebfb9e3c_07166f45ebf5bbdd.jpg)













Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
