answer.
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
maw [93]
2 years ago
15

Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output

for the given program:
Computers and Technology
2 answers:
Drupady [299]2 years ago
8 0

#include <iostream>

using namespace std;

class CarCounter {

  public:

     CarCounter();

     CarCounter(const CarCounter& origCarCounter);

     void SetCarCount(const int count) {

         carCount = count;

     }

     int GetCarCount() const {

         return carCount;

     }

  private:

     int carCount;

};

CarCounter::CarCounter() {

  carCount = 0;

  return;

}

CarCounter::CarCounter(const CarCounter &p){

carCount = p.carCount;

}

void CountPrinter(CarCounter carCntr) {

  cout << "Cars counted: " << carCntr.GetCarCount();

  return;

}

int main() {

  CarCounter parkingLot;

  parkingLot.SetCarCount(5);

  CountPrinter(parkingLot);

  return 0;

}

Sample output:  

Cars Counted: 5

katen-ka-za [31]2 years ago
7 0

Answer:

import java.util.Comparator;

import java.util.PriorityQueue;

 

public class PriorityQueueTest {

 

static class PQsort implements Comparator<Integer> {

 

 public int compare(Integer one, Integer two) {

 return two - one;

 }

}

 

public static void main(String[] args) {

 int[] ia = { 1, 10, 5, 3, 4, 7, 6, 9, 8 };

 PriorityQueue<Integer> pq1 = new PriorityQueue<Integer>();

 

 // use offer() method to add elements to the PriorityQueue pq1

 for (int x : ia) {

 pq1.offer(x);

 }

 

 System.out.println("pq1: " + pq1);

 

 PQsort pqs = new PQsort();

 PriorityQueue<Integer> pq2 = new PriorityQueue<Integer>(10, pqs);

 // In this particular case, we can simply use Collections.reverseOrder()

 // instead of self-defined comparator

 for (int x : ia) {

 pq2.offer(x);

 }

 

 System.out.println("pq2: " + pq2);

 

 // print size

 System.out.println("size: " + pq2.size());

 // return highest priority element in the queue without removing it

 System.out.println("peek: " + pq2.peek());

 // print size

 System.out.println("size: " + pq2.size());

 // return highest priority element and removes it from the queue

 System.out.println("poll: " + pq2.poll());

 // print size

 System.out.println("size: " + pq2.size());

 

 System.out.print("pq2: " + pq2);

 

}

}

You might be interested in
Multiple boolean expressions can be combined by using a logical operator to create ________ expressions.
Licemer1 [7]
<span>Boolean expressions can be combined by using a logical operator to create compound expressions. A boolean expression is an expression that takes into account and evaluates specific data, which is in the form of true and/or false. A compound expression is merely a statement of expressions.</span>
8 0
1 year ago
Cooper Technologies is a technology company that offers many IT services in Chicago. The company's services and products include
yuradex [85]

Answer:

d. broad needs and few customers.

Explanation:

This strategy is based on creation of unique and valuable persons.

Broad needs and few customers (Wealth Management )

Wealth management is a service that combines to address the needs of clients. Wealth Management utilizes financial discipline such as financial and investment , accounting and tax.This service is appropriate for individuals with broad array of diverse needs.

4 0
2 years ago
. Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Ca
Whitepunk [10]

Answer:

  1. from matplotlib import pyplot as plt
  2. with open("text.txt") as file:
  3.    data = file.readlines()
  4.    category = []
  5.    amount = []
  6.    for row in data:
  7.        values = row.split(" ")
  8.        category.append(values[0])
  9.        amount.append(float(values[1]))
  10.    
  11. figure = plt.figure()
  12. ax = figure.add_axes([0,0,1,1])
  13. ax.axis('equal')
  14. ax.pie(amount, labels = category, autopct='%1.2f%%')
  15. plt.show()

Explanation:

Firstly, we need to import matplotlib library (Line 1).

Next, open a file stream and use readlines method to read the data from the text file (Line 4). Presume the data read from the text files are as follows:

Rent 450

Gas 150

Food 500

Clothing 120

Car 600

Create two lists, category and amount (Line 5-6). Use a for loop to traverse through the read data and use split method to break each row of data into two individual items. The first item is added to category list whereas the second item is added to amount list (Line 7 - 10).

Next, create a plot figure and then add the axes (Line 12 - 13). We can use the pie method to generate a pie chart (Line 15) by setting the amount list as first argument and category list as value of labels attributes. The output pie chart can be found in the attachment.

7 0
2 years ago
A regional bank implemented an automated solution to streamline their operations for receiving and processing checks/cheques. Th
Sphinxa [80]

Answer: Machine learning

Explanation:

The technology that could be combined with the current solution to do this is the machine learning.

Machine learning refers to the use and development of the computer systems which can learn and adapt without them following explicit instructions. This is done through the use of statistical models and algorithms in order to analyse inferences from the patterns in data.

Since the bank wants to streamline their operations for the receiving and processing checks while also enhancing the solution to recognize signs of potential check fraud, then the machine learning can be used.

3 0
1 year ago
When a file is transferred between two computers, two acknowledgment strategies are possible. in the first one, the file is chop
ra1l [238]
The TCP/IP stack is responsible for the "chopping up" into packets of the data for transmission and for their acknowledgment. Depending on the transport protocol that is used (TCP or UDP) each packet will be <span>acknowledged or not, respectively.
</span><span>the strategy when the file is chopped up into packets, which are individually acknowledged by the receiver, but the file transfer as a whole is not acknowledged is OK in situations (Applications) that do not need the whole file to be sent, Web site for example: different parts of the web site can arrive in different times.

The other strategy, in which </span><span>the packets are not acknowledged individually, but the entire file is acknowledged when it arrives is suitable for FTP (mail transfer), we need whole mail, not parts of it. </span>
5 0
2 years ago
Other questions:
  • When driving, your attention is __________.
    5·2 answers
  • Annabeth has been using a public cloud to store and access her documents. Which drawback of a public cloud should she be aware o
    11·1 answer
  • Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
    11·1 answer
  • // This pseudocode is intended to determine whether students have
    5·1 answer
  • Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
    15·1 answer
  • Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
    7·2 answers
  • You have been employed as a technical consultant to a computer shop chain. You are given the task of creating a short consumer b
    12·1 answer
  • PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
    6·1 answer
  • Why is it important for element IDs to have meaningful names?
    11·1 answer
  • Write a loop to populate the list user_guesses with a number of guesses. The variable num_guesses is the number of guesses the u
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!