Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; import java.util.ArrayList; public class DataVisualizer { private final String title; private final String authorNameColumn; private final String numNovelsColumn; private final ArrayList dataPoints; public
import java.util.Scanner;
import java.util.ArrayList;
public class DataVisualizer
private final String title;
private final String authorNameColumn;
private final String numNovelsColumn;
private final ArrayList dataPoints;
public DataVisualizerString title, String authorNameColumn, String numNovelsColumn
this.title title;
this.authorNameColumn authorNameColumn;
this.numNovelsColumn numNovelsColumn;
this.dataPoints new ArrayList;
public static void mainString args
Scanner scanner new ScannerSystemin;
System.out.printlnEnter a title for the data";
String title scanner.nextLine;
System.out.printlnYou entered: title;
System.out.printlnEnter the column header:";
String cHeader scanner.nextLine;
System.out.printlnYou entered: cHeader;
System.out.printlnEnter the column header";
String cHeader scanner.nextLine;
System.out.printlnYou entered: cHeader;
DataVisualizer dv new DataVisualizertitle cHeader, cHeader;
boolean done false;
do
System.out.printlnEnter a data point Enter to stop input:;
String input scanner.nextLine;
if inputequals
done true;
else
try
if input.contains
throw new ExceptionError: No comma in string.";
if inputlastIndexOf input.indexOf
throw new ExceptionError: Too many commas in input.";
String dataArray input.split;
String author dataArraytrim;
int novelQty Integer.parseIntdataArraytrim;
System.out.printlnData string: author;
System.out.printlnData integer: novelQty;
dvdataPoints.addnew DataPointauthor novelQty;
catch NumberFormatException nfe
System.out.printlnError: Comma not followed by an integer.";
catch Exception e
System.out.printlnegetMessage;
while done;
System.out.printlndv;
private void printTable
private void printHistogram
@Override
public String toString
private static class DataPoint
private final String author;
private final int novelQty;
public DataPointString author, int novelQty
this.author author;
this.novelQty novelQty;
can anyone help me correct my gramlical errors
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started