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
Which Access database object asks a question about the data stored in a database and displays specific fields and records that a
AVprozaik [17]

Answer: Query

Explanation:

It is through the process of queries a user is able to ask questions about the data stored in the database and view specific fields as required. These queries can be of many type and each time using a query would give us the desired fields.

7 0
3 years ago
Which tag will you use if you want your web page to look the same as your source code?
Stolb23 [73]

Answer:

The <samp> element allows you to output sample code as output.

The <pre> element also provides you the choice to output exactly what written in the source code

Explanation:

The two tags affords you the chance of outputting exactly what you have in the source code as your outputs.

6 0
3 years ago
Identify 5 internal and external hardware components of a server
UNO [17]

Answer:

Internal:

#CPU; That retrieves &execute instructions.

#Modem; Modulates& demodulates electric signals.

#RAM;Gives application a place to store &access data on a short time periods.

External:

#Mouse; Transmits commands and controlling movements.

#Moniter; Device used to display video output from computer.

#Printer; Accepts text, graphics to the paper.

Explanation:

Hope this will help you.

5 0
2 years ago
Can some one fix this <br> input ("Enter a number: ") <br> print (num * 8)
Kaylis [27]
If you save the input as num,
this will print the input 8 times.

num = input("Enter a number: ")
print(num * 8)

If you want to do actual math calculations,
then the input needs to be a number.

num = float(input("Enter a number: "))
print(num * 8)

This doesn't account for any errors in which the user doesn't input a number, but I don't think that's what you were looking for anyway :)
6 0
3 years ago
(1) Prompt the user for an automobile service. Output the user's input. (1 pt) Ex: Enter desired auto service: Oil change You en
Pavlova-9 [17]

Answer:

In Python:

#1

service = input("Enter desired auto service: ")

print("You entered: "+service)

#2

if service.lower() == "oil change":

   print("Cost of oil change: $35")

elif service.lower() == "car wash":

   print("Cost of car wash: $7")

elif service.lower() == "tire rotation":

   print("Cost of tire rotation: $19")

else:

   print("Invalid Service")

Explanation:

First, we prompt the user for the auto service

service = input("Enter desired auto service: ")

Next, we print the service entered

print("You entered: "+service)

Next, we check if the service entered is available (irrespective of the sentence case used for input). If yes, the cost of the service is printed.

This is achieved using the following if conditions

For Oil Change

<em>if service.lower() == "oil change":</em>

<em>    print("Cost of oil change: $35")</em>

For Car wash

<em>elif service.lower() == "car wash":</em>

<em>    print("Cost of car wash: $7")</em>

For Tire rotation

<em>elif service.lower() == "tire rotation":</em>

<em>    print("Cost of tire rotation: $19")</em>

Any service different from the above three, is invalid

<em>else:</em>

<em>    print("Invalid Service")</em>

<em></em>

6 0
3 years ago
Other questions:
  • The spreadsheet below shows the names years in office, and number of terms for five US presidents
    7·2 answers
  • A plan that outlines the steps and timeline for reaching a certain goal is called a(n):
    13·1 answer
  • What is the resistance of a 1,000-foot length of #6 AWG wire at a temperature of 25 degrees C? A. 0.1593 ohm B. 0.4028 ohm C. 0.
    7·1 answer
  • A tool you might use to manipulate an image, such as a photograph, into a seamless repeating texture would be:
    7·2 answers
  • Black Ops 3 For Ps4 Players Here
    7·1 answer
  • How can you tell that a spreadsheet was saved as a 2007 Excel file?
    7·1 answer
  • You are attempting to upgrade a Windows Server 2008 R2 server to Windows Server 2016 Standard. What must be done in order to acc
    5·1 answer
  • Who is the intended audience of a pseudocode document?
    14·1 answer
  • in Python we use IDE ( lntegrated Dvelopment Environment ) to write down the program data points of difference between script mo
    13·1 answer
  • QueSUUN TU
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!