package application; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import java.io.IOException; import java.util.List; import java.io.FileReader; public class CustomerOrderHistory { public static void main(String[] args) { // variables String csvFile = "C:\\Users\\Student\\IdeaProjects\\OrderDetailsDisplayNew\\src\\main\\resources\\orders.csv"; //appstream with drive letter try ( FileReader fileReader = new FileReader(csvFile); CSVParser csvParser = CSVFormat.DEFAULT.withHeader().parse(fileReader) ) { // List creates a list of all rows in the csv file ['el1','el2',...] List orders = csvParser.getRecords(); // loop using for x in ys // for (type var : ys) // ys orders for (CSVRecord order : orders ) { // headers subTotal,tax,total String header1 = "subTotal"; String subTotal = order.get(header1); String tax = order.get("tax"); String total = order.get("total"); System.out.println("Order Details"); System.out.println("=============="); System.out.println("Subtotal: $" + subTotal); System.out.println("Tax: $" + tax); System.out.println("Total Amount :$" + total); } // for } // try catch (IOException err) { System.out.println("Error: " + err); } catch (Exception err) { System.out.println("Error: " + err); } finally { System.out.println("Thank you for using our app!"); } } //main() } // CustomerOrderHistory