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
The instant pivot button is displayed in the statistics and visualization tabs when a _______ search is run.
Arisa [49]

Answer:

<h2>The instant pivot button is displayed in the statistics and visualization tabs when a <u>non-transforming</u>  search is run. </h2>

Explanation:

<h3>Transforming Search:</h3>

It can be defined as a search in which transforming commands are used that involve, charts and stats to convert data of events that is gained by the search in to tables (statistical). These tables can further be used for the basis of visualizing data in the form of charts.

Non-Transforming Search:

The search that do no contains produce event lists that can be viewed in Events tab. while using non-transforming search, i we want to generate tables or charts we must follow the points below:

  • Click ob statistics and Visualization tab.
  • Select pivot to open the search.
  • All the visualizations can be generated in this editor.

<h2>i hope it will help you!</h2>
5 0
4 years ago
A virus is a self-replicating program that produces its own code by attaching copies of it into other executable codes.
Allisa [31]

Answer: Stealth/Tunneling Virus

Explanation: Stealth or tunneling virus are the virus which are responsible for attacking a computer system which causes the problem in the functioning of the operating system by manipulating files, creating partition etc.

These viruses try to avoid or prevent the anti-virus scans for the detection any sort of virus or error . They act to prevent any malfunction detection by taking charge for the anti-virus operation.

5 0
3 years ago
How are ip addresses available to the internet classified?
Olegator [25]
Public






--------------------------------------------------
7 0
4 years ago
In cyberspace, bret attempts to steal consumers' credit card numbers stored in the networked computers of cinco corporation, a f
Mandarinka [93]

The quantity of data that can be stolen is limited by the same physical limits that exist in the real world.

Quantitative data is defined as data that can be measured in numerical values. The two main kinds of quantitative data are discrete data and continuous data. Height in feet, age in years, and weight in pounds are examples of quantitative data. Qualitative data can be described as descriptive data that is not expressed numerically. Data quality means a measure of the condition of data based on factors such as accuracy, completeness, consistency, reliability and whether it's up to date.

You can learn more about the quantitative data at brainly.com/question/96076

#SPJ4

5 0
2 years ago
Hardy doesn't have access to a work template, which is on the network server. What should he do?
BabaBlast [244]

Answer:

Allow access.

Explanation:

Network server is a type of central repository (file server), where computers connected to it can access files stored in the repository. There can be other types of network server, besides file server, like printer server.

Network server are usually not available over the internet and require users to connect to a local network (intranet), in order to access it.

The server is managed by an administrator. One of the jobs of the administrator is to password protect and/or add users to the server.

4 0
4 years ago
Other questions:
  • The rules that establish an orderly transfer of data between sender and receiver are called ____.
    5·2 answers
  • TCP waits until it has received three duplicate ACKs before performing a fast retransmit. Why do you think the TCP designers cho
    13·1 answer
  • 2. Identify the diagram and define it.<br>13. What are pollen grains ?<br>4. What is an embryo?​
    12·1 answer
  • Write the DML statement to query the database for the following: Output the fname, lname, total_amount_owed of the student with
    5·1 answer
  • In the Sender Message Channel Receiver (SMCR) model, the ______ is the large, bureaucratic organization that produces messages.
    5·1 answer
  • ASAP PLZ!!!!!! Select the correct answer from each drop-down menu. Complete the sentences related to the types of sample data. I
    7·1 answer
  • What are some common predefined number formats used in the United States? Check all that apply.
    15·1 answer
  • Digital security measures include _____. Select 2 options.
    11·2 answers
  • A print server uses a print ________ as a software holding area for jobs waiting to be printed.
    5·2 answers
  • How has the internet improved business communication worldwide
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!