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
Which girl is he baddest 1. Shawty 2.Lisa 3.Ashley
Ainat [17]

Answer:

. . . . . . . S H A W T Y.. . .. . .

3 0
3 years ago
Write a program that displays a menu allowing the user to select air water, or steel. After the user has made a selection, the n
luda_lava [24]

Answer:

// Program is written in C++ Programming Language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main ()

{

// Declare Variable

int selection;

// Prompt user to make a selection of medium between air, water or steel.

cout<<"Make Selection"<<'\n'<<"Press 1 for Air"<<'\n'<<"Press 2 for Water"<<'\n'<<"Press 3 for Steel";

cin>>selection;

// Check for entry

if(selection == 1) {

cout<<"You selected Air"<<'\n';

cout<<"The distance travelled by sound wave in air is 1,125 feet in 1 second";

}

else if(selection == 2) {

cout<<"You selected Water"<<'\n';

cout<<"The distance travelled by sound wave in water is 4859 feet in 1 second";

}

else if(selection == 3) {

cout<<"You selected Steel"<<'\n';

cout<<"The distance travelled by sound wave in steel is 19554 feet in 1 second";

}

else

cout<<"Invalid Selection";

return 0;

}

7 0
3 years ago
Chang is a network engineer. He is revising the company's firewall implementation procedure. As part of this work, he is reviewi
erastovalidia [21]

Answer:

d

Explanation:

3 0
3 years ago
Which of the following is not a component of Google Display ads' value proposition?
Evgesh-ka [11]

Answer:

D. Search.

Explanation:

Google search engine is a engine used in browsers to seek of information related to the search values inputted by the user. This search engine is used in varieties of browsers like google chrome, mozilla firefox, phoenix etc, this is because it has a wide range of Google community web servers to get information.

Google Display ads value proposition is an advertising platform that takes advantage of the enormous google community on the internet of advertise client products and services across thousands of websites.

It uses the intent of the costumer, machine learning and performance of a website to advertise products, it does not need a search component since it is advertised automatically on an active website.

6 0
3 years ago
You have been tasked with ensuring that access to certain server managed resources is only available to client devices with TPM
elixir [45]

Answer:

Device Health Attestation Services

Explanation:

Based on the scenario being described it can be said that the Windows Server role that can be used to automate this check is known as Device Health Attestation Services. This is a role that allows the administrator to automatically check if a device has the required trustworthy BIOS, TPM, or boot software enabled, as well as Bitlocker encryption.

7 0
3 years ago
Other questions:
  • The ________ of the operating system enables users to communicate with the computer system. modem window network adapter card us
    14·1 answer
  • A _____________ is a method of controlled entry into a facility and provides access to secure areas such as a research lab or da
    10·1 answer
  • A text-only forum accessed through a bulletin board service (BBS) is known as a _____.
    14·1 answer
  • What are the two major components of a processor cooler assembly?
    15·1 answer
  • There is an application which inputs hundred numbers from the user, if user enters a positive number it increments valid numbers
    6·1 answer
  • __________ refers to rules, statutes, codes, and regulations established to provide a legal framework within which business may
    13·1 answer
  • Similarities between drawing toolbar and editing toolbar​
    12·2 answers
  • Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
    10·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
  • The full meaning of UNIVAC and ENIAC​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!