Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am getting an error in this saying I'm declaring an invalid method, I have tried fixing it but I am not sure what it

I am getting an error in this saying I'm declaring an invalid method, I have tried fixing it but I am not sure what it wrong?

public class ItemToPurchase { //Private fields - itemName, itemPrice, and itemQuantity private String itemName(); private int itemPrice(); private int itemQuantity();

*/ public ItemToPurhcase() { itemName = ""; itemPrice = 0; itemQuantity = 0; return; } //public member methods (mutators & accessors) //set name public void setName(String Name) { itemName = Name; return; } //get name public String getName() { return itemName; } //set price public void setPrice(int Price) { itemPrice = Price; return; } //get price public int getPrice() { return itemPrice; } //set quantity public void setQuantity(int Quantity) { itemQuantity = Quantity; return; } //get quantity public int getQuantity() { return itemQuantity; } //print item to purchase public void printItemPurchase() { System.out.println(itemQuantity + " " + itemName + " $" + itemPrice + " = $" + (itemPrice * itemQuantity)); } }

image text in transcribed
zy Section 5.12 - IT 145: Intro to Sof X + V X > C a learn.zybooks.com/zybook/IT-145-12043-OL-TRAD-UG.22EW2/chapter/5/section/12 OF A =zyBooks My library > IT 145: Intro to Software Development home > 5.12: Online shopping cart (Java) zyBooks catalog Help/FAQ Angelita Paulson 32 33 } //get price 34 public int getprice() { Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) melon 5 6 hat 8 3 Run program Input (from above) Item ToPurchase.java (Your program) Output (shown below) Program errors displayed here ItemToPurchase. java: 12: error: invalid method declaration; return type required public ItemToPurhcase () { 1 error Coding trail of your work What is this? 11/25 F-- U- 0 min : 56 Trouble with lab? 2:33 PM Sunny Search 11/27/2022

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions