I really am stuck as to what I am doing wrong with this program. Help would be much appreciated :D.

// DiscountPrices.java - This program calculates total cost for discounted items. 
// Input:  Interactive.
// Output:  Original price, discount, discounted price, and total price for all items. 

import javax.swing.*;

public class DiscountPrices
{
 public static void main(String args[]) 
 {
  final double DISCOUNT_ONE = .05;
  final double DISCOUNT_TWO = .10;
  final double DISCOUNT_THREE = .15;
  double price;
  String priceString;
  int quantity;               
  String quantityString; 
  double originalPrice;
  priceString = JOptionPane.showInputDialog("Enter price of item: ");
  originalPrice = Double.parseDouble(priceString); 
  quantityString = JOptionPane.showInputDialog("Enter quantity ordered: ");
  quantity = Integer.parseInt(quantityString); 
  
  // Test price here and call calculatePrice method.  
  {
    While (originalPrice < 5.00);
    {
      price = originalPrice * DISCOUNT_ONE;}
    
  While(originalPrice < 10.00);
  {
    price = originalPrice * DISCOUNT_TWO;
  }
   While(originalPrice >10.00);
   { price = originalPrice * DISCOUNT_THREE;
  }
 
calculatePrice(price, quantity);

System.out.println(done);  
  
   
    
 
  System.exit(0);
  }
   // End of main() method.
 
 
 // Write calculatePrice method here.
  {
  public static double calculatePrice(){
    double total = (price * quantity)*
     string done = ("Price: = " + originalPrice + "Discount Percent: " + ((originalPrice - price)/100) + "Quantity: " + quantity + "Total: " + total);
return done;
}


} // End of DiscountPrices class.

thanks.

Recommended Answers

All 2 Replies

Ok let me clarify where the one error is. It's in the last module, and tells me that the 'public static double calculatePrice(){ line is an illegal start to the expression. I'd really appreciate some advice on it.

It's because of the open brace '{' you have right before it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.