Skip to main content

Practice ยท 3 of 4

Receipt line, decomposed

Implement two cooperating methods: - static String formatMoney(double amount) โ€” formats as $NN.NN with exactly two decimals (formatMoney(5) is $5.00). - static String line(String item, int qty, double price) โ€” returns "item xN = $NN.NN" where the money part comes from formatMoney of qty * price. Example: line("pen", 3, 1.5) is "pen x3 = $4.50".

Difficulty: beginner

Back to lesson: Practice: Practice: Utility Library