Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: 1- Create a class, called Product with: A private data field called code (String) A private data field called price (double) A private data

image text in transcribed

Question: 1- Create a class, called Product with: A private data field called code (String) A private data field called price (double) A private data field called quantity (int) A private data field called discount (double) A constructor that create a Product with specify code, price and quantity Get and set methods for price, quantity and discount Get for code To String that return a String as follow: Product C100 with price 12.5 $, quantity 12 and discount 12.5% A void method: public void apply Discount() That update the price according to the discount: price=price*(1-discount/100) 2. Write a java application that contains a. A method that return that product with maximum price from an array of products P public static Product maxPrice(Product[] P) b. A method that return the sum of all available items from all products in an array P Public static int countProducts(Product [] P) C. A test main that: Create an array of 5 products Fill array from user Print the description of product with maximum price Apply the discount on all products in the array Print the description of all products Print the number of all items in the array

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

what are the organization changes

Answered: 1 week ago