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]
2 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]2 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
Given the function F (X, Y , Z)=Σm(0,1, 2 , 4 , 6)
Mnenie [13.5K]

Answer:

(1)Minterms complement = XYZ (2) Compliment of Minterms = Σm(0,1, 2 , 4 , 6) (3) (X+Y+Z) (4) Minimized SOP = Z + XY

Manterms = πM

Explanation:

Solution

Recall that:

Given the function F (X, Y , Z)=Σm(0,1, 2 , 4 , 6)

(1) Canonical Disjunctive Normal Form: In boolean algebra, the boolean function can be expressed as Canonical Disjunctive form known as minterms

In Minterm we assign 'I' to each uncomplimented variable and '0' to each complemented/complementary variable

For the given question stated we ave the following:

Minterms = XYZ, XYZ, XYZ, XYZ, XYZ.

(2) Canonical Conjunctive Normal Form: In boolean algebra, the boolean function can be expressed as Canonical Disjunctive form known as maxterms.

In Maxterms we assign '0' to each uncomplimented variable and '1' to each complemented/complementary variable

Compliment of Minterms = Σm(0,1, 2 , 4 , 6)

Maxterms = πM

Note: Kindly find an attached copy of the complete solution to this question below.

6 0
2 years ago
. What process skill would a scientist use to find the length of a line
Brilliant_brown [7]

Answer:

Explanation:

A ruler

;););););););););););););););)

7 0
3 years ago
The presentation ____ determines the formatting characteristics of fonts and colors.
leonid [27]
The presentation theme determines the formatting characteristics of fonts and colors.
6 0
3 years ago
Read 2 more answers
Why are wiki's not secure​
Nookie1986 [14]
Wikipedia is not a reliable source for citations elsewhere on Wikipedia. Because, as a user-generated source, it can be edited by anyone at any time, any information it contains at a particular time could be vandalism
7 0
2 years ago
How should your fingers rest upon the home row keys?
xxTIMURxx [149]

Answer:

Your left index finger should rest on the "f" key which can be found easily by using your touching senses because there is a bump on the "f" , and the "j" Key your right index finger should rest on the "j" Key, Your thumbs can rest on the space bar

7 0
2 years ago
Other questions:
  • What is intensity? this is for digital arts
    12·1 answer
  • )a___ is a complete binary tree such that each node in the tree contains a comparable object that us greater than or equal to th
    9·1 answer
  • What does mean I can’t turn on my computer and my computer won’t charge at all
    15·1 answer
  • If I wanted to include a picture of a dog in my document, I could use _____. SmartArt WordArt clip art AutoCorrect
    13·1 answer
  • A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
    5·1 answer
  • Hyper-Tech Enterprises manufactures mechanical parts used in air conditioning and heating units. The company employs over 300 wo
    13·1 answer
  • Match the parts of the website address with its correct explanation. http://www.usa.gov/Agencies/federal.shtm/​
    5·2 answers
  • Edhesive in JAVA Write a method that takes a String parameter. If the String has a double letter (i.e. contains the same letter
    13·1 answer
  • State the Limitations of the first generation of computers​
    8·1 answer
  • You can merge the cells using the rowspan and colspan attribute of the tag <br> true or false​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!