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
klemol [59]
3 years ago
14

Suppose that class OrderList has a private attribute double cost[100] which hold the cost of all ordered items, and a private at

tributes int num_of_items which hold the number of items ordered. For example, if num_of_items is 5, then cost[0], cost[1], ..., cost[4] hold the cost of these 5 items. Implement the member function named total_cost which returns the total cost of this OrderList.
Computers and Technology
1 answer:
harina [27]3 years ago
7 0

Answer:

<u>OrderList.java</u>

  1. public class OrderList {
  2.    private double cost[];
  3.    private int num_of_items;
  4.    
  5.    public OrderList(){
  6.        cost = new double[100];
  7.    }
  8.    public double total_cost(){
  9.        double total = 0;
  10.        for(int i=0; i < num_of_items; i++){
  11.            total += cost[i];
  12.        }
  13.        return total;
  14.    }
  15. }

<u>Main.java</u>

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        OrderList sample = new OrderList();
  4.        double totalCost = sample.total_cost();
  5.    }
  6. }

Explanation:

Firstly, define a class OrderList with two private attributes, cost and num_of_items (Line 1-3). In the constructor, initialize the cost attribute with a double type array with size 100. Next, create another method total_cost() to calculate the total cost of items (Line 9-15). To implement the total_cost member function, create an OrderList instance and use that instance to call the total_cost() and assign it to totalCost variable.

You might be interested in
A potentiometer a three wire variable resistor is used in which type of sensor ?
NARA [144]

<u>A potentiometer a three wire variable resistor is used in </u><u>Throttle position (TPS) Sensor.</u>

<u />

Explanation:

A <u>potentiomete</u>r is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. In case only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat.

A<u> throttle position sensor (TPS) </u>is a sensor which is  used to monitor the air intake by  an engine. This sensor is usually located on the shaft or the butterfly spindle because it can be directly  be used to use the position of the <u>THROTTLE</u>

The T<u>hrottle Position Sensor (TPS)  is a part of Fuel Management system of a vechile.The proper function of Throttle Position Sensor (TPS) ensures that the right amount of fuel and air is delivered to the vechile engine.</u>

6 0
4 years ago
What is one benefit of Powerpoint Online?
VashaNatasha [74]

Answer:

for edge users

anyone with the url

Explanation:

6 0
3 years ago
Read 2 more answers
You're the administrator for a large bottling company. At the end of each month, you routinely view all logs and look for discre
Natali [406]

Answer:

It seems as though it would be a DDoS attack.

Explanation:

The characteristics are as follows:

A slow down of operations and attempting to get access into said service.

4 0
3 years ago
You have been asked to investigate a web server for possible intrusion. You identify a script with the following code. What lang
nignag [31]

The code below is written in JavaScript and does not seem malicious.

<h3>What is a Malicious Code?</h3>

A Malicious code is one that is not designed for any productive end but to cause disruptions in the computer with the objective of

  • harming the workstation; or
  • destroying the data stored therein.

There are numerous classifications of malicious codes and they can be identified and removed by an application called an Anti-Virus or malicious app remover.

Learn more about JavaScript at:
brainly.com/question/16698901

8 0
3 years ago
Help!!!
Butoxors [25]

Answer:

ummmm try the inequality protragathron theorum

Explanation:

ok

3 0
3 years ago
Other questions:
  • You work for a large enterprise company that handles time-sensitive information. Your supervisor has asked that you set up a con
    8·1 answer
  • Which of the following is true about a point-and-shoot camera? They always have lenses that you can take on and off. They are of
    8·2 answers
  • It is appropriate to leave sections of an application blank ?<br><br><br><br> True or False
    7·1 answer
  • To create a default value for a parameter in the parameter list of a function, you code a/an ________________ sign after the par
    5·1 answer
  • What is the name of the technology that is typically implemented on switches to avoid Ethernet connectivity problems when the wr
    11·1 answer
  • Fill _________ skips the Saturday and Sunday dates in a date fill.
    10·1 answer
  • Which of the following makes Super Mario Run unique?
    6·1 answer
  • Define operating system?explain the types of operating system on the basis of use.​
    7·1 answer
  • Which hardware component interprets and carries out the instructions contained in the software.
    12·1 answer
  • automatic updates are better than non-automatic updates for a system because it might be better for patching the os as they narr
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!