#System.out.printf error
1 messages ยท Page 1 of 1 (latest)
Can you send the snippet of code that has printf
Im not seeing a printf statement in the block above
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)
// 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.");
}
}
Thanks
Weird, the statements aren't throwing any exceptions for me when I run it
Hmm
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)
No Im not, my prof says not to using anything but the one she uses
Ill try the fix youve sent ty
Damn
Well if you decide to continue with Java on your own past this course, u can use IntelliJ for personal projects or something
Thanks for the suggestion ๐ will look into it when Im not upset about having to deal with eclipse
Ya I didn't enjoy eclipse either but I was lucky enough to have a professor that let us use any IDE we wanted
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 ๐