Answered step by step
Verified Expert Solution
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
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
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