1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alinara [238K]
3 years ago
8

Write a class called Product. The class should have fields called name, amount, and price, holding the product’s name, the numbe

r of items of that product in stock, and the regular price of the product. There should be a method get_price that receives the number of items to be bought and returns as the cost of buying that many items, where the regular price is charged for orders of less than 10 items, a 10% discount is applied for orders of between 10 and 99 items, and a 20% discount is applied for orders of 100 or more items. There should also be a method called make_purchase that receives the number of items to be bought and decreases amount by that much.
Computers and Technology
1 answer:
vichka [17]3 years ago
5 0

Answer:

public class Product {

//Declaring the fields

   private String name;

   private int amount;

   private double price;

   //Constructor

   public Product(String name, int amount, double price) {

       this.name = name;

       this.amount = amount;

       this.price = price;

   }

   // The method get_price

   public double get_price(int amount){

       // amount of goods less than 10

       if(amount<10){

           double zeroDiscPrice;

           zeroDiscPrice = this.price;

           return zeroDiscPrice;

       }

       // amount of goods less than 100

       else if(amount>=10 && amount<100){

           double tenPercentDiscPrice;

           tenPercentDiscPrice = this.price-(this.price*0.1);

           return tenPercentDiscPrice;

       }

       // amount of goods greater than 100

       else{

           double twentyPercentDiscPrice;

           twentyPercentDiscPrice = this.price-(this.price*0.2);

           return twentyPercentDiscPrice;

       }

   }

}

Explanation:

The class is implemented in Java programming language

Three member variables (fields) are declared as described in the question

A constructor is created to initialize an instance of the class

The method get_price() as created uses a combination of if...else if....else To determing the price based on the amount of items bought as described in the question.

You might be interested in
Given the following code, what is output by the method call, mystery(6 * 8)? public static void mystery (int x[]) { System.out.p
____ [38]

Answer:

B

Explanation:

This question demonstrates the concept of method overloading

Method overloading means having different versions of the same method. In this case the method mystery() has three versions. The compiler is able to determine which method to call by their different parameters

The first implementation of mystery requires an array of integers as parameter

The second implementation requires an int variable

The third implementation requires a String

The Method call mystery(6 * 8) will output B because 6*8 evaluates to an integer which is the expected argument.

7 0
3 years ago
Dotted Decimal Notation was created to______________. Group of answer choices provide an alternative to IP addressing express ea
BaLLatris [955]

Answer:

Both b and c

Explanation:

Dotted Decimal notation is a presentation of numerical data which is expressed as decimal numbers separated by full stops. Dotted decimal notation expresses each eight bit sections of 32 bit numbers as decimal value. It provides convenient notation which is easy to understand by the people who are IT experts.

3 0
3 years ago
Me Completan Pliiiis
Brut [27]
Can you translate please i’ll help better
4 0
3 years ago
Jack is writing a paragraph for a school assignment. He proofreads his paper and notices that he used the word, "then" many time
Lynna [10]

He should use a Thesaurus.

5 0
4 years ago
Read 2 more answers
What is astronaut favourite key on keyboard? ​
Dennis_Churaev [7]

Answer:

The space bar is an astronauts favorite key

5 0
3 years ago
Read 2 more answers
Other questions:
  • Ports on the motherboard can be disabled or enabled in ____ setup. RAM Firmware Northbridge BIOS
    8·1 answer
  • 6 The part of the computer that contains the brain or central processing unit is also known as the ?
    11·1 answer
  • If I make a Zoom Meeting, would you join it?
    7·2 answers
  • Access Control can be defined as putting controls (or countermeasures) in place to help achieve information security goals. Whic
    13·2 answers
  • Gray London is a retired race car driver who helped Dale Earnhardt, Jr. get his start. He is writing a book and making a video a
    9·1 answer
  • Dennis would like to include a video in a presentation. The source of the video is on the internet, but he would like to ensure
    10·2 answers
  • I need help <br> with a question<br> what can i write for ex when he mad
    13·2 answers
  • The New option is found in the ...............tab.​
    6·2 answers
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
  • Answer the following question in 3-4 complete sentences. Define the following terms: - registration - press - keyblock.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!