Question: HOW CAN I PRINT LIKE THIS FROM THI CODE public class Test8 { public static void main(String[] args) throws FileNotFoundException { String row; Scanner in
HOW CAN I PRINT LIKE THIS FROM THI CODE

public class Test8 {
public static void main(String[] args) throws FileNotFoundException {
String row; Scanner in = new Scanner(System.in); System.out.print("Enter a date (YYYY-MM-DD): "); // asking user for the date String date = in.nextLine();
in.close();
File file = new File("all-states-history-new.csv");
Scanner scans = new Scanner(file);
int [] cCases = new int [12];
for (int x = 0; x
row = scans.nextLine(); //if row is printed it will print entire file
if (date.equals(getColumn(1,row))) { String totalRow= getColumn(22,row); int k= Integer.parseInt(totalRow);
if(k==0){ cCases[0]++; } else if (k>0 and k500 and k1000 and k1500 and k2000 and k2500 and k3000 and k3500 and k4000 and k4500 and k5000){ cCases[11]++; } } }
}
for (int i=0; i
} System.out.println();
}
public static void printLabel(int n) {
if (n==0) {System.out.printf(" %10s:", "0");}
else if (n>10) { System.out.printf(" %10s:",">5000");}
else {System.out.printf(" %10s:", (n-1)*500+1+"-"+n*500);}
}
public static String getColumn(int s, String row) {
int x = 0; //variables going to be used
String data = "";
String returnedData = "";
Scanner scansTwo = new Scanner(row).useDelimiter(","); // moves through commas using Delimiter
while (x
data = scansTwo.next();
if (++x == s) returnedData = data; //returns data
}
scansTwo.close();
return returnedData;
}
}
Enter a date (YYYY-MM-DD): 2021-02-15 0: ****** 1-500: ******* **** 501-1000: ********* 1001-1500: ****** 1501-2000: ***** 2001-2500: ** 2501-3000: * 3001-3500: 3501-4000: ** 4001-4501: 4501-5000: >5000: ** Below is a run for 2021-01-15. The program shows that a majority of states had over 5000 new cases on that day. Note how much better the COVID situation was in mid-F mid- January. Whew! Enter a date (YYYY-MM-DD): 2021-01-15 0: *** 1-500: ******** 501-1000: ****** 1001-1500: ****** 1501-2000: *** 2001-2500: *** 2501-3000: ***** 3001-3500: ** 3501-4000: *** 4001-4501: * 4501-5000: *** >5000: ************** Enter a date (YYYY-MM-DD): 2021-02-15 0: ****** 1-500: ******* **** 501-1000: ********* 1001-1500: ****** 1501-2000: ***** 2001-2500: ** 2501-3000: * 3001-3500: 3501-4000: ** 4001-4501: 4501-5000: >5000: ** Below is a run for 2021-01-15. The program shows that a majority of states had over 5000 new cases on that day. Note how much better the COVID situation was in mid-F mid- January. Whew! Enter a date (YYYY-MM-DD): 2021-01-15 0: *** 1-500: ******** 501-1000: ****** 1001-1500: ****** 1501-2000: *** 2001-2500: *** 2501-3000: ***** 3001-3500: ** 3501-4000: *** 4001-4501: * 4501-5000: *** >5000: **************
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
