← Back to Printing
Question 25
Complex Mixed Format
Complex Mixed Format
Create variables: String item = "Laptop", int quantity = 3, float price = 899.99f. Calculate the total cost (quantity * price) and useSystem.out.printf()to create this formatted output the output shown in Expected Output. Use%sfor the string,%03dfor the quantity (zero-padded to 3 digits), and%.2ffor both price values. Make sure each piece of information appears on its own line.
Expected Output:
Product: Laptop Qty: 003 Price: $899.99 Total: $2699.97
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Printing
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.