Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; public class Product { / / Build Product class with public methods and private fields listed above / * Type your code here.
import java.util.Scanner;
public class Product
Build Product class with public methods and private fields listed above
Type your code here.
main
public static void mainString args
String name "Apple";
double price ;
int num ;
Product prod new Productname price, num;
Test Are instance variables setreturned properly?
System.out.printlnName: prod.getCode;
System.out.printfPrice: f
prod.getPrice;
System.out.printlnCount: prod.getCount;
System.out.println;
Test Are instance variables setreturned properly after adding and selling?
num ;
prod.addInventorynum;
num ;
prod.sellInventorynum;
System.out.printlnName: prod.getCode;
System.out.printfPrice: f
prod.getPrice;
System.out.printlnCount: prod.getCount;
System.out.println;
Test Do setters work properly?
name "Golden Delicious";
prod.setCodename;
price ;
prod.setPriceprice;
num ;
prod.setCountnum;
System.out.printlnName: prod.getCode;
System.out.printfPrice: f
prod.getPrice;
System.out.printlnCount: prod.getCount;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started