As it says, I'm having problems with this code in this exercise. My teacher says its straight forward, but he really hasn't been a reliable source of knowledge.
I'm not asking for help finishing this exercise (well, at least not ENTIRELY), I'm asking if some kind folks are willing to help these lines make sense to me, because my teachers lessons make about as much sense as reading a book about Philosophy and trying to explain it to a 5 year old...
I've highlighted the areas and gave them some underline spots instead of the [insert code here] stuff he had there.
Thanks again in advance to whoever is willing to help.
// Make it possible to use required packaged code import [COLOR="Red"] java.util[/COLOR]; import java.io.*; import java.text.*; // This class defines a program to process orders for a fast food restaurant. // ---- Written by: Jon Huhtala // --- Modified by: My name public class Project02 { // This method begins application processing. public static void main(String[] args) { // Variables. double taxRate; // For holding the tax rate. String reply; // For holding the user's latest keyboard entry. ArrayList quantities; // For holding the item quantities for the // customer order. // These coordinated arrays hold item names and their prices String[] items = {"Burgers", "Fries", "Drinks"}; double[] prices = {2.75, 1.50, 1.35}; // If the program did not receive a command line parameter, set the // tax rate to .06 (meaning 6%). Otherwise, set the tax rate to the // value of the parameter. if ([COLOR="Red"]_______________[/COLOR] == 0) { taxRate = .06; } else { String taxRateAsString =[COLOR="Red"] __________[/COLOR]; // GET PARAMETER VALUE. taxRate =[COLOR="Red"] ____________[/COLOR](taxRateAsString); // CONVERT FROM String TO double. } // Loop to process one customer order. do { // Display item names and prices. System.out.println(""); System.out.println("--------- ITEMS AND PRICES ---------"); System.out.println(""); // THIS LOOP SHOULD DISPLAY ITEM NAMES AND PRICES IN A FORMAT THAT // MATCHES THE SAMPLE OUTPUT SHOWN BELOW. for (int i = 0; i < [COLOR="Red"]______._____[/COLOR]; i++) { // LIMIT BY SIZE OF items ARRAY. System.out.println(" " +[COLOR="Red"] ________ [/COLOR]+ "..." + Utility.moneyFormat([COLOR="Red"]________[/COLOR])); } // Get order data. System.out.println(""); System.out.println("------------ YOUR ORDER ------------"); System.out.println(""); quantities = new ArrayList(); // THIS LOOP SHOULD PROMPT FOR AND READ THE NUMBER OF EACH ITEM THE // CUSTOMER WANTS TO BUY. IT SHOULD MATCH THE FORMAT OF THE SAMPLE // OUTPUT SHOWN BELOW. for (int i = 0; i < [COLOR="Red"]______._____[/COLOR]; i++) { // LIMIT BY SIZE OF items ARRAY. System.out.print(" Number of " +[COLOR="Red"] _____________[/COLOR] + ": "); reply = Utility.readString(); quantities.[COLOR="Red"]______________[/COLOR]; // ADD TO THE quantities ArrayList. } // Calculate and display "Payment Due" information. System.out.println(""); System.out.println("----------- PAYMENT DUE ------------"); System.out.println(""); double subtotal = calculate(prices, quantities); System.out.println(" Subtotal: " + Utility.moneyFormat(subtotal)); double tax = subtotal * taxRate; System.out.println(" Tax: " + Utility.moneyFormat(tax) + " at " + [COLOR="Red"]__________[/COLOR]); // SHOW taxRate AS FORMATTED PERCENTAGE. double totalDue = subtotal + tax; System.out.println(" TOTAL: " + Utility.moneyFormat(totalDue)); // Ask the user if they want to process another order. If they reply with // a String whose value is "YES", repeat this loop. System.out.println(""); System.out.println("-------------- AGAIN? --------------"); System.out.println(""); System.out.print(" Enter YES to do another order: "); reply = Utility.readString(); } while ([COLOR="Red"]____________[/COLOR]); // ACCEPT "YES" IN ANY CASE (LIKE "yes") TO CONTINUE. } // This method can be called to calculate the non-taxable amount due for // an order. It receives the array of prices and ArrayList of corresponding // quantities as parameters. public static double calculate([COLOR="Red"]____________, _____________________[/COLOR]) { double total = 0; for (int i = 0; i < [COLOR="Red"]______._______[/COLOR]; i++) { // LIMIT BY SIZE OF THE ARRAY. double price = [COLOR="Red"]_____________________[/COLOR]; // GET THE ITEM'S PRICE. int quantity = [COLOR="Red"]_____________________[/COLOR]; // GET CORRESPONDING QUANTITY ORDERED. double extendedPrice = price * quantity; total += extendedPrice; } return total; } } // This class contains custom methods that support application processing. // ----- Written by: Jon Huhtala class Utility { private static BufferedReader kbReader = new BufferedReader(new InputStreamReader(System.in)); // This method read a String value from the keyboard. public static String readString() { String result = null; while (result == null) { try { result = kbReader.readLine(); } catch(Exception err) { System.out.print("ERROR! Please try again: "); } } return result; } // This method converts a double to a formatted currency String. // For example: 1234.56 --> "$1,234.56" public static String moneyFormat(double amount) { return NumberFormat.getCurrencyInstance().format(amount); } // This method converts a double to a formatted percentage String // having exactly one decimal place. // For example: .075 --> "7.5%" public static String percentFormat(double amount) { NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMaximumFractionDigits(1); nf.setMinimumFractionDigits(1); return nf.format(amount); } }