Note that there are some explanatory texts on larger screens.

plurals
  1. POCSC java Receipt
    text
    copied!<p>I need to make a receipt formatted as best i can like a normal receipt. With a name and address, time and date all at the top. (all of which need to be user input.) </p> <p><strong>main code</strong></p> <pre><code> //Removed Imports class ReceiptCode { public static void main(String[] args) { // TODO Auto-generated method stub //Font f = new Font("Calibri", Font.BOLD, 20); Scanner scan= new Scanner(System.in); System.out.println("Enter Company Name"); String companyName= scan.nextLine(); System.out.println("Enter STREET ADDRESS"); String street=scan.nextLine(); System.out.println("Enter CITY, STATE, ZIP"); String CSZ=scan.nextLine(); String breaker = "------------------------------"; List &lt;Items&gt; invList = new ArrayList&lt;Items&gt;(); System.out.println("How many items did you order?"); int counter = scan.nextInt(); double totalPrice = 0; for (int i=0; i&lt;counter; i++) { System.out.println("Name the item"); String fName = scan.next(); System.out.println("How many of this item did you order?"); int fType = scan.nextInt(); System.out.println("What was the price?"); double fPrice = scan.nextDouble(); Items inv = new Items(fName, fType, fPrice); double x = (fType * fPrice); totalPrice += x; invList.add(inv); System.out.println(totalPrice); } DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); DateFormat timeFormat = new SimpleDateFormat ("HH:mm"); Date date = new Date(); Date time = new Date(); System.out.printf("%-15s %n", companyName); System.out.printf("%-15s %14s %n",street + "\n" + CSZ,dateFormat.format(date)); System.out.printf("%-15s %14s %n", timeFormat.format(time)); System.out.println(breaker); for (Items c : invList) { System.out.println (c.getFoodAmmount() + " x " + c.getFoodName() + " : " + c.getFoodPrice() + "$"); System.out.println (breaker); } } } </code></pre> <p>This is the class for my Items Array List </p> <p><strong>ArrayList</strong></p> <pre><code>package Receipt; public class Items { private String foodName; private int foodAmmount; private double foodPrice; public Items (String fdType, int fdAmmount, double fdPrice) { foodName = fdType; foodAmmount = fdAmmount; foodPrice = fdPrice; } public String getFoodName() { return foodName; } public int getFoodAmmount() { return foodAmmount; } public double getFoodPrice() { return foodPrice; } } </code></pre> <p>When I compile the code I recieve an exception regarding: <code>Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '14s'</code>. How would I go about fixing this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload