I have been scrounging about, trying to get to compile this properly, but I get a stupid error message at the end.

I also do not know how to implement an accumulator into the methods, could someone at least teach me how to implement one? Into Main, or just a separate method?

Thanks for any help.

import java.util.Scanner;
public class OrderSystem {
/**
*
*
*
*/
    private static final Scanner scanner = new Scanner(System.in);
    
    // Books
    public static final int BOOKS_NUM = 1;
    public static final String BOOKS_NAME = "Books";
    
    public static final int POTTER_NUM = 1;
    public static final String POTTER_NAME = "Harry Potter";
    public static final double POTTER_PRICE = 19.99;
    
    public static final int INKHEART_NUM = 2;
    public static final String INKHEART_NAME = "Inkheart";
    public static final double INKHEART_PRICE = 8.29;
    
    public static final int HOBBIT_NUM = 3;
    public static final String HOBBIT_NAME = "The Hobbit";
    public static final double HOBBIT_PRICE = 12.50;
    
    public static final int HOWL_NUM = 4;
    public static final String HOWL_NAME = "Howl's Moving Castle";
    public static final double HOWL_PRICE = 22.00;
    
    // Movies
    public static final int MOVIES_NUM = 2;
    public static final String MOVIES_NAME = "Movies";
    
    public static final int MER_NUM = 1;
    public static final String MER_NAME = "The Little Mermaid";
    public static final double MER_PRICE = 16.89;
    
    public static final int ALADDIN_NUM = 2;
    public static final String ALADDIN_NAME = "Aladdin";
    public static final double ALADDIN_PRICE = 14.33;
    
    public static final int LION_NUM = 3;
    public static final String LION_NAME = "The Lion King";
    public static final double LION_PRICE = 14.62;
    
    public static final int BEAST_NUM = 4;
    public static final String BEAST_NAME = "Beauty and the Beast";
    public static final double BEAST_PRICE = 17.70;
    
    // Music
    public static final int MUSIC_NUM = 3;
    public static final String MUSIC_NAME = "Music";
    
    public static final int HANSON_NUM = 1;
    public static final String HANSON_NAME = "Hanson / Middle of Nowhere";
    public static final double HANSON_PRICE = 21.30;
    
    public static final int IRON_NUM = 2;
    public static final String IRON_NAME = "Iron Maiden / Live After Death";
    public static final double IRON_PRICE = 23.19;
    
    public static final int METAL_NUM = 3;
    public static final String METAL_NAME = "Metallica / Metallica";
    public static final double METAL_PRICE = 15.00;
    
    public static final int LADY_NUM = 4;
    public static final String LADY_NAME = "Lady Gaga / The Fame Monster";
    public static final double LADY_PRICE = 29.15;
    
    public static final double books = 0, movies = 0, music = 0;
    public static final double numItems = books + movies + music;
    
    public static final double booksPrice = POTTER_PRICE + INKHEART_PRICE + HOBBIT_PRICE + HOWL_PRICE;
    public static final double moviesPrice = MER_PRICE + ALADDIN_PRICE + LION_PRICE + BEAST_PRICE;
    public static final double musicPrice = HANSON_PRICE + IRON_PRICE + METAL_PRICE + LADY_PRICE;
    
    public static final double numBooks =+ books;
    public static final double numMovies =+ movies;
    public static final double numMusic =+ music;
        
    public static final double booksAverage = booksPrice / numBooks;
    public static final double moviesAverage = moviesPrice / numMovies;
    public static final double musicAverage = musicPrice / numMusic;
    
    public static final double displayTaxRate() {
    	double taxRate = 0.00;
    	
    	do {
    		System.out.printf("%s", "What is the tax rate for this transaction (in percent)? ");
    		taxRate = scanner.nextDouble();
    		if(taxRate > 100.00 || taxRate < 0.00){
    			System.out.printf("%s", "Tax rate must be between 0 and 100.\n");
    		}
    		else {
    			taxRate /= 100;
    			return taxRate;
    		}
    	}
    	while (true);
    }
        
    public static final int displayWholeMenu() {
    	int categoryChoice = 0;
    	 
    	do {
    		System.out.printf("%d. %-20s\n", BOOKS_NUM, BOOKS_NAME);
    		System.out.printf("%d. %-20s\n", MOVIES_NUM, MOVIES_NAME);
    	    System.out.printf("%d. %-20s\n", MUSIC_NUM, MUSIC_NAME);
    	    System.out.printf("%s", "Choice: ");
    	    categoryChoice = scanner.nextInt();
    	    if(categoryChoice == 1 || categoryChoice == 2 || categoryChoice == 3){
    	        return categoryChoice;
            } else if (categoryChoice < 1 || categoryChoice > 3) {
                boolean user1 = userInput1();
                continue;
            }
    	}
    	while (true);
    }

            
    public static final int displayCatBooks() {
    	int books = 0;
    	do {
    		System.out.printf("%d. %-20s\n", POTTER_NUM, POTTER_NAME, POTTER_PRICE);
            System.out.printf("%d. %-20s\n", INKHEART_NUM, INKHEART_NAME, INKHEART_PRICE);
            System.out.printf("%d. %-20s\n", HOBBIT_NUM, HOBBIT_NAME, HOBBIT_PRICE);
            System.out.printf("%d. %-20s\n", HOWL_NUM, HOWL_NAME, HOWL_PRICE);
            System.out.printf("%s", "Choose an item: ");
            books = scanner.nextInt();
            if(books == 1 || books == 2 || books == 3 || books == 4){
                boolean user2 = userInput1();
                return books;                
            } else if (books < 1 || books > 4) {
                continue;
            }
        }
    	while (true);
    }

    
    public static final int displayCatMovies(){
    	int movies = 0;
    	do {
    		System.out.printf("%d. %-20s\n", MER_NUM, MER_NAME, MER_PRICE);
            System.out.printf("%d. %-20s\n", ALADDIN_NUM, ALADDIN_NAME, ALADDIN_PRICE);
            System.out.printf("%d. %-20s\n", LION_NUM, LION_NAME, LION_PRICE);
            System.out.printf("%d. %-20s\n", BEAST_NUM, BEAST_NAME, BEAST_PRICE);
            System.out.printf("%s", "Choose an item: ");
            movies = scanner.nextInt();
            if(movies == 1 || movies == 2 || movies == 3 || movies == 4){
                boolean user3 = userInput1();
                return movies;
            } else if (movies < 1 || movies > 4) {
                continue;
            }
        }
    	while (true);
    }
    
    public static final int displayCatMusic(){
    	int music = 0;
    	do {
    		System.out.printf("%d. %-20s\n", HANSON_NUM, HANSON_NAME, HANSON_PRICE);
            System.out.printf("%d. %-20s\n", IRON_NUM, IRON_NAME, IRON_PRICE);
            System.out.printf("%d. %-20s\n", METAL_NUM, METAL_NAME, METAL_PRICE);
            System.out.printf("%d. %-20s\n", LADY_NUM, LADY_NAME, LADY_PRICE);
            System.out.printf("%s", "Choose an item: ");
            music = scanner.nextInt();
            if(music == 1 || music == 2 || music == 3 || music == 4){
                boolean user4 = userInput1();
                return music;
            } else if (music < 1 || music > 4) {
                continue;
            }
        }
    	while (true);
    }
    
    public static boolean userInput1(){
        System.out.print("Would you like another item? (y/n) ");
        if('y' == scanner.next().charAt(0)) {// returns true if they typed y, else false
            return true;
        }
        return false;
    }
    
    public static boolean userInput2(){
        System.out.print("Would you like to place another order? (y/n) ");
        if('y' == scanner.next().charAt(0)) {// returns true if they typed y, else false
            return true;
        }
        return false;
    }
    public static void displayOrderSummary(){
    
    	System.out.printf("%s", "Order Summary:\n");
    	System.out.printf("%d Books(s)   $ %2.2f / Average $ %2.2f\n" , numBooks , booksPrice , booksAverage);
    	System.out.printf("%d Movie(s)   $ %2.2f / Average $ %2.2f\n" , numMovies , moviesPrice , moviesAverage);
    	System.out.printf("%d CD(s)      $ %2.2f / Average $ %2.2f\n" , numMusic , musicPrice , musicAverage);
    }

    public static final double displaySubTotal(double booksPrice, double moviesPrice, double musicPrice){
        
    	return booksPrice + moviesPrice + musicPrice;
    }
    
    public static final double displayTax(double subTotal, double taxRate){
        
        return subTotal * taxRate;
    }
    
    public static final double displayTotalPrice(double subTotal, double tax){
        
        return subTotal + tax;
    }
    
    public static final double displayAveragePrice(double totalPrice, double numItems){
       
        return totalPrice / numItems;
    }
    
    public static void main(String args[]) throws Exception {
    	System.out.println("This is order processing software.");  
        
        double taxRate = displayTaxRate();        
        
        int categoryChoice = displayWholeMenu();
        int books = displayCatBooks();
        int movies = displayCatMovies();
        int music = displayCatMusic();
                
        double subTotal = displaySubTotal(booksPrice, moviesPrice, musicPrice); 
        System.out.printf("%d. %-20s\n", subTotal);        
        double tax = displayTax(subTotal, taxRate);
        System.out.printf("%d. %-20s\n", taxRate);
        double totalPrice = displayTotalPrice(subTotal, tax);
        System.out.printf("%d. %-20s\n", totalPrice);
        double average = displayAveragePrice(totalPrice, numItems);
        System.out.printf("%d. %-20s\n", average);
        
        boolean user5 = userInput2();
    }
}

Exception in thread "main" java.util.IllegalFormatConversionException: d !

and so on...

Its a huge error message right at the end.

You're using printf incorrectly.

System.out.printf("%d. %-20s\n", POTTER_NUM, POTTER_NAME, POTTER_PRICE);
System.out.printf("%s", "What is the tax rate for this transaction (in percent)? ");

Only the first one would cause an error, but the second one should just be the second String - you have no need to say %s instead of just quoting the String, do you?

In the first one, it might be complaining because you have three arguments but only two format specifiers (i.e. the %d and %s are format specifiers).

You have similar errors all over.

But for the second one, I do not get an error. Only toward the end, with the main method

I also cannot figure out how to implement an accumulator in this program. My friend told me a switch statement needs to be created, but I have no idea how to do that in the main method?

System.out.printf("%d. %-20s\n", average);

Like I said, similar errors all over. You either have the wrong type of argument or the wrong number of arguments. You're doing this all over the place. You told it to expect an integer followed by a String, but you only passed in "average" (which I'm assuming is an integer).

System.out.printf("%d. %-20s\n", average, "");

You have to pass it a String if you put %s.

I also cannot figure out how to implement an accumulator in this program. My friend told me a switch statement needs to be created, but I have no idea how to do that in the main method?

Fix your printf errors first. Whether or not it produces an error message doesn't matter. There are logical errors and compiler errors. Your program has both right now, it is important to get rid of them. And I don't know what an accumulator is .

I think it might be too late. The assignment is due in about 30 minutes.

Doesn't matter. Without a complete rewrite to use proper OO techniques and actually have it be Java rather than Basic using Java syntax you should get a major fail on that assignment anyway.

I think it might be too late. The assignment is due in about 30 minutes.

wow ... talking about efficiƫnt time management :|

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.