#System.out.printf error

1 messages ยท Page 1 of 1 (latest)

empty wedgeBOT
#

Helper please have a look, thanks.

earnest pendant
#

Can you send the snippet of code that has printf

#

Im not seeing a printf statement in the block above

plush sandal
#

the printf is underlined n doesnt run

#

and get this error: Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, double)
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, double)
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, double)

at pizza.PizzaOrder.main(PizzaOrder.java:127)
earnest pendant
#

Give me a moment

#

Can you copy paste the printf statements in here rq

plush sandal
#
// Apply discount if the user is eligible (Task #4)
        if (discount) {
            System.out.println("You are eligible for a discount!");
            cost *= 0.9; // Apply a 10% discount
        }

        // Format money output with two decimal places (Task #5)
        System.out.printf("The cost of your order is: $%.2f\n", cost);

        tax = cost * TAX_RATE;
        System.out.printf("The tax is: $%.2f\n", tax);
        System.out.printf("The total due is: $%.2f\n", (tax + cost));

        System.out.println("Your order will be ready for pickup in 30 minutes.");
    }
}
earnest pendant
#

Thanks

#

Weird, the statements aren't throwing any exceptions for me when I run it

plush sandal
#

I tried it online complier it works there aswell

#

But in eclipse it gives an error

earnest pendant
#

Hmm

plush sandal
#

Im not sure if its eclipse or just the code

earnest pendant
#

Can you try following the first answer on this page

#

This should be the same issue you're having

#

Also on another note I recommend using IntelliJ IDE instead of eclipse (if youre able to)

plush sandal
#

No Im not, my prof says not to using anything but the one she uses

#

Ill try the fix youve sent ty

earnest pendant
#

Damn

#

Well if you decide to continue with Java on your own past this course, u can use IntelliJ for personal projects or something

plush sandal
#

Thanks for the suggestion ๐Ÿ™‚ will look into it when Im not upset about having to deal with eclipse

earnest pendant
#

Ya I didn't enjoy eclipse either but I was lucky enough to have a professor that let us use any IDE we wanted

empty wedgeBOT
#

Closed the thread due to inactivity.

If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you ๐Ÿ‘