Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the below program skeleton. Replace the four <add code here> items so that

ID: 3791896 • Letter: G

Question

Given the below program skeleton. Replace the four <add code here> items so that the program produces the below output. Try to mimic the output’s format precisely, but it’s OK if your column widths vary slightly from the shown column widths.
public class CarInventoryReport
{
      public static void main (String[]   args)
      {
          final String HEADING_FMT_STR = <add code here> ;
          final String DATA_FMT_STR =   <add code here> ;
          String item1 = “Mazda RX-8” ;
          int qtyl     = 10 ;
          double price1 = 27999.99 ;
          String item2 = “MINI Cooper” ;
          int qty2 = 100 ;
          double price2 = 23000.25 ;
         
          System.out.printf(HEADING_FMT_STR,
                “Item” , “Quantity”, “Price”, “Value”) ;
          System.out.printf (HEADING_FMT_STR,
          System.out.printf(DATA_FMT_STR < add code here>) ;
        System.ou.printf (DATA_FMT_STR, ,add code here) ;
}    // end main
} // end class CarInventoryReport

Output:
Item Quanity Price Value
------ ---------- ------- --------
Mazda RX-8         10 28,000 280,000   
MINI Cooper       100 23,000 2,300,025

Explanation / Answer

public class CarInventoryReport
{
      public static void main (String[]   args)
      {
          final String HEADING_FMT_STR = " --------------------------------";
          final String DATA_FMT_STR =   " %s %d    %,.0f %,.0f ";
          String item1 =   "Mazda RX-8" ;
          int qty1    = 10 ;
          double price1 = 27999.99 ;
          String item2 = "MINI Cooper" ;
          int qty2 = 100 ;
          double price2 = 23000.25 ;
       
          System.out.printf(HEADING_FMT_STR +" Item Quantity   Price   Value") ;
          System.out.printf (HEADING_FMT_STR);
          System.out.printf(DATA_FMT_STR ,item1,qty1,price1,qty1*price1) ;
        System.out.printf (DATA_FMT_STR,item2,qty2,price2,qty2*price2) ;
}    // end main
} // end class CarInventoryReport

output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote