Answered step by step
Verified Expert Solution
Link Copied!

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 main(String args[]){
String name = "Apple";
double price =0.40;
int num =3;
Product prod = new Product(name, price, num);
// Test 1- Are instance variables set/returned properly?
System.out.println("Name: "+ prod.getCode());
System.out.printf("Price: %.2f
", prod.getPrice());
System.out.println("Count: "+ prod.getCount());
System.out.println();
// Test 2- Are instance variables set/returned properly after adding and selling?
num =10;
prod.addInventory(num);
num =5;
prod.sellInventory(num);
System.out.println("Name: "+ prod.getCode());
System.out.printf("Price: %.2f
", prod.getPrice());
System.out.println("Count: "+ prod.getCount());
System.out.println();
// Test 3- Do setters work properly?
name = "Golden Delicious";
prod.setCode(name);
price =0.55;
prod.setPrice(price);
num =4;
prod.setCount(num);
System.out.println("Name: "+ prod.getCode());
System.out.printf("Price: %.2f
", prod.getPrice());
System.out.println("Count: "+ prod.getCount());
}
}

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

I What about this organization makes you want to be a part of it?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago