Question: Please convert this program from JAVA to C. import java.util.ArrayList; import java.util.Scanner; public class Novels { public static void main(String[] args) { Scanner scan =

Please convert this program from JAVA to C.

import java.util.ArrayList; import java.util.Scanner;

public class Novels {

public static void main(String[] args) { Scanner scan = new Scanner(System.in); ArrayList dataStr = new ArrayList(); ArrayList dataPoint = new ArrayList(); System.out.print("Enter a title for the data: "); String title = scan.nextLine(); System.out.println("You entered: "+title); System.out.print("Enter the column 1 header: "); String header1 = scan.nextLine(); System.out.println("You entered: "+header1); System.out.print("Enter the column 2 header: "); String header2 = scan.nextLine(); System.out.println("You entered: "+header2); while(true){ System.out.print("Enter a data point (-1 to stop input): "); String s = scan.nextLine(); if(s.equals("-1")){ break; } else{ String str[] = s.split(","); if(str.length == 1){ System.out.println("Error: No comma in string."); } else if(str.length > 2){ System.out.println("Error: Too many commas in input."); } else { try{ int point = Integer.parseInt(str[1].trim()); dataPoint.add(point); dataStr.add(str[0]); System.out.println("Data string: "+str[0]); System.out.println("Data integer: "+point); }catch(NumberFormatException e){ System.out.println("Error: Comma not followed by an integer."); } } } }

System.out.printf("%33s ",title); System.out.printf("%-20s|%23s ",header1,header2); System.out.println("-------------------------------------"); for(int i=0; i

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!