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

Can someone tell what\'s wrong with this part of the program. It\'s giving me an

ID: 3673223 • Letter: C

Question


Can someone tell what's wrong with this part of the program. It's giving me an error on the 1st line saying the string literal is not properly closed by a double quote. When I do have a double quote..

//outputting data system. out.println (" system. out . println (t Description Units on Hand Price") system. out.println(" rP //accessor function calls syst en. out .printIn("Item #1 "+r1. get Description() + "ltit"+r1.getUnits )+" ltlt "+rl.get Price ()) system. out . println ("Item #2 "4r2. get Description() + " "+r2. getUnits )" lt "+r2.getPrice )); #3 "+r3. getDescription() +"t "tr3.getUnits )+"tlt "+r3. get Price )); System.out. print In("Item

Explanation / Answer

public class RetailItem {

   String description;
   int units;
   double price;

   public RetailItem() {
       // TODO Auto-generated constructor stub
   }

   /**
   * @param description
   * @param units
   * @param price
   */
   public RetailItem(String description, int units, double price) {
       super();
       this.description = description;
       this.units = units;
       this.price = price;
   }

   /**
   * @return the description
   */
   public String getDescription() {
       return description;
   }

   /**
   * @return the units
   */
   public int getUnits() {
       return units;
   }

   /**
   * @return the price
   */
   public double getPrice() {
       return price;
   }

   /**
   * @param description
   * the description to set
   */
   public void setDescription(String description) {
       this.description = description;
   }

   /**
   * @param units
   * the units to set
   */
   public void setUnits(int units) {
       this.units = units;
   }

   /**
   * @param price
   * the price to set
   */
   public void setPrice(double price) {
       this.price = price;
   }

   public static void main(String[] args) {

       String str = "Shirt";

       // RetailItem with the three objects
       RetailItem r1 = new RetailItem("Jacket", 12, 59.95);
       RetailItem r2 = new RetailItem("Designer Jeans", 40, 34.95);
       RetailItem r3 = new RetailItem();
       // function call to set value
       r3.setDescription(str);
       r3.setUnits(20);
       r3.setPrice(24.95);

       System.out.println("_________________________ _____________________");
       System.out.println(" Description Units on Hand Price");
       System.out.println("__________________________ _____________________");
       // accessor function calls
       System.out.println("Item #1 " + r1.getDescription() + " "
               + r1.getUnits() + " " + r1.getPrice());
       System.out.println("Item #2 " + r2.getDescription() + " "
               + r2.getUnits() + " " + r2.getPrice());
       System.out.println("Item #3 " + r3.getDescription() + " "
               + r3.getUnits() + " " + r3.getPrice());
   }
}

OUTPUT:

_________________________ _____________________
   Description   Units on Hand   Price
__________________________ _____________________
Item #1   Jacket       12        59.95
Item #2   Designer Jeans       40        34.95
Item #3   Shirt       20        24.95

NOTE: please check the constructors and setter and getters

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