So far this is the code I have. It will successfully read the contents of the file(which are below in quotations) and write them to the designated file. My issue is totaling the corresponding costs to their services and then writing that to the file. The if and else if clauses above do not work but how is it that I can get them working? Any help would be appreciated, thank you.import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; public class logBook { public static void main(String[] args) throws FileNotFoundException { File inputFile = new File("C:\\Users\\Desktop\\Log.txt"); Scanner in = new Scanner(inputFile); try{ PrintWriter out = new PrintWriter("C:\\Users\\Desktop\\OutputLog.Txt"); while(in.hasNextLine()) { in.useDelimiter(";"); String clientName = in.next(); String serviceCost = in.next(); Double cost = Double.parseDouble (serviceCost.trim() ); String serviceSold = in.next(); if(serviceSold.equals("Dinner")) { double totalDinner = ; totalDinner += cost; System.out.print(totalDinner); } else if(serviceSold.equals("Lodging")) { double totalLodging = 0; totalLodging += cost; System.out.print(totalLodging); } else if(serviceSold.equals("Conference")) { double totalConference = 0; totalConference += cost; System.out.print(totalConference); } String serviceDate = in.next(); in.nextLine(); out.println(clientName); out.println(cost); out.println(serviceSold); out.println(serviceDate); } out.close(); in.close(); } catch(FileNotFoundException e) { e.printStackTrace(); } } }
"John; 67.00; Dinner ; Aug 12 2013;
Bob; 200.00; Conference; Sep 11 2013;
Clara; 450.00; Lodging; Oct 25 2013;
Jamie; 450.00; Lodging; Oct 28 2013;
Rachel; 67.00; Dinner; Nov 11 2013;
Richard; 200.00; Conference; Dec 17 2013;
Nick; 67.00; Dinner; Jan 05 2014;"