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]
2 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]2 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
Problem 1 (Authentication): Consider the following authentication protocol, which uses a classical cryptosystem. Alice generates
Elis [28]

Answer:

Check the explanation

Explanation:

Yes, going by the question above, the protocol validates Bob to Alice for the reason that the key is only shared between Bob and Alice as well as the number which is being sent randomly. Therefore the invader won’t be able to predict and response to that number. Because of the authentication protocol, that makes use of a classical cryptosystem thereby resulting into the possibility of an argument such that key finding is attainable via invader.

5 0
3 years ago
Care and feeding for computer
o-na [289]
Don’t drop it and charge it regularly
5 0
3 years ago
Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
konstantin123 [22]

Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

<h3>What is Parameter variable?</h3>

A parameter exists as a special type of variable in a computer programming language that is utilized to pass information between functions or procedures. The actual information passed exists called an argument. A parameter exists as a named variable passed into a function. Parameter variables exist used to import arguments into functions.

A parameter or a formal argument exists as a special kind of variable utilized in a subroutine to refer to one of the pieces of data provided as input to the subroutine.

The call-by-value process of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function maintain no effect on the argument. By default, C++ utilizes call-by-value to pass arguments.

Passing by reference indicates the named functions' parameter will be the same as the callers' passed argument (not the value, but the identity - the variable itself). Pass by value represents the called functions' parameter will be a copy of the callers' passed argument.

Hence, Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

To learn more about Parameter variable refer to:

brainly.com/question/15242521

#SPJ4

6 0
1 year ago
In basic network scanning, ICMP Echo Requests (type 8) are sent to host computers from the attacker, who waits for which type of
Hoochie [10]

Answer:

d. ICMP Echo Reply (type 0)

Explanation:

ICMP or internet control message protocol is an Internet layer protocol in the TCP/IP suite. It works together with routing devices like the router to send messages based on results sensed in the network.

The RFC 1122 has stated that the ICMP server and end user application be configured or installed in user devices, for receiving and sending ICMP echo request packets and reply. The process is called pinging.

For an attacker to implement ping of ping, he needs to confirm if the target user in live by sending an ICMP echo request packet type 8, to receive an ICMP echo reply type0.

4 0
2 years ago
Which type of image is not a supported using the Online Pictures or Insert Picture command?
IgorC [24]

Answer:

HTML  i think

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Operating system software allows you to use your fingers, a mouse or other pointing device to select screen controls, such as bu
    5·2 answers
  • Write the pseudocode for linear search, which scans through the sequence, looking for ν. Using a loop invariant, prove that your
    14·1 answer
  • Which type of communication is usually handwriten
    11·2 answers
  • Martha wants to invite her coworkers to her birthday party. She uses the mail merge feature to compose and send the invitations.
    6·1 answer
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Declare a char array named ssn suitable for
    5·1 answer
  • A Tracking Gantt chart is based on the percentage of work completed for project tasks or the actual start and finish dates. True
    12·1 answer
  • Which soft skills would these mobile app developers need to use in the situations described?
    8·2 answers
  • A time stamp indicates the date and time that a measurement was taken. A data scientist has a list containing 10,000 time stamps
    6·1 answer
  • try the following code to see a nullpointer error (if you don’t see the error because of the autograding, you can copy it into t
    15·1 answer
  • Write l for law of enrtia,ll for law of Acceleration and lll for law of enteraction.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!