please help me Java I need to Complet the code for the metho

please help me Java

I need to Complet the code for the method.

my code link: https://codeshare.io/D1Pew

where I need put if statment, %10d %5d(speace)

Solution

Here is the code for you:

import javax.swing.JOptionPane;
import java.text.*;
import java.util.*;
class TotalBill
{
/*
Here is question
Complet the code for the method printReceipt below. It accepts an ArrayList of string objects and array of doubles as its two arguments. It will produce a recipt for the items puechesd displayed in a JOptionPane with a Monospaced Font.
the item names are in the ArratList. The price of each item is in the array. Assume the longest name is 10 charaters and the prices are all <=9.99 Note: each line pis 22 spaced wide.
*/
public static void printReceipt(ArrayList<String> menuItems, double[] prices)
{
   String numSTR, lines;
  
   double total = 0;
  
   NumberFormat fmt=NumberFormat.getCurrencyInstance();
  
   lines= \" Your Receipt\ \";//4 spaces
  
   lines+= \"Item Price\ \";//13 spaces
   for(int i =0; i < menuItems.size();i++)
   {
       numSTR = String.format(\"%10s\\t$%.2lf\ \", menuItems.get(i), prices[i]);
      
       lines +=numSTR;
      
       total +=prices[i];
   }
   lines +=\"----------------------\ \";
   lines += System.out.format(\"Total\\t\\t$%.2lf\ \", total);//creat total line
   //Complete the code to display lines in the JOptionPane
   /*I need code*/
   JOptionPane.showMessageDialog (null, lines);
}//end of method
}

If you need any refinements, just get back to me.

please help me Java I need to Complet the code for the method. my code link: https://codeshare.io/D1Pew where I need put if statment, %10d %5d(speace)SolutionHe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site