I have a project I am doing for class and I have everything filled the way I think it is supposed to be but I am getting a couple errors that I can not seem to fix. I was wondering if anyone can give me a suggestion. Here is the program.
import java.util.*;
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: Andy Rayburn
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 (taxRate == 0) {
taxRate = .06;
}
else {
String taxRateAsString = " "; // GET PARAMETER VALUE.
taxRate = Double.parseDouble (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 < items.length; i++) { // LIMIT BY SIZE OF items ARRAY.
System.out.println(" " + items[i] + "..." + Utility.moneyFormat(taxRate));
}
// 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 < items.length; i++) { // LIMIT BY SIZE OF items ARRAY.
System.out.print(" Number of " + items[i] + ": ");
reply = Utility.readString();
quantities.add (items); // 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 " + (" taxrate * 100" + " % ")); // 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 ( reply == "yes"); // 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(int order, double amount) {
double total = 0;
for (int i = 0; i < prices.length; i++) { // LIMIT BY SIZE OF THE ARRAY.
double price = amount; // GET THE ITEM'S PRICE.
int quantity = order; // GET CORRESPONDING QUANTITY ORDERED.
double extendedPrice = price * quantity;
total += extendedPrice;
}
return total;
}
}
The errors I am getting are as follow.
Project02.java:79: calculate(int,double in Project02 cannot be applied to (double[],java.util.arraylist)
double subtotal = calculate(prices, quatities):
Project02.java:104: cannot find symbol
symbol : varible prices
location: class Project02
for (int i=0: i < prices.length; i++) {
Please help
thanks