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
Elina [12.6K]
2 years ago
8

Create two classes. The first, named Sale, holds data for a sales transaction. Its private data members include the day of the m

onth, amount of the sale, and the salesperson's ID number. The second class, named Salesperson, holds data for a salesperson, and its private data members include each salesperson's ID number and last name. Each class includes a constructor to which you can pass the field values. Create a friend function named display()that is a friend of both classes and displays the date of sale, the amount, and the salesperson ID and name. Write a short main()demonstration program to test your classes and friend function.Sample Run
Sale #103 on 12/25/2016 for $559.95 sold by #103 Woods
Sale #106 on 11/15/2016 for $359.95 sold by #106 Hansen
Computers and Technology
1 answer:
olya-2409 [2.1K]2 years ago
4 0

Answer:

A C++ program was used in creating two classes. the code is stated below.

Explanation:

Solution

The C++ program is executed below:

#include<iostream>

using namespace std;

//declare class (will be define later)

class Salesperson;

//class Sale

class Sale

{

  //private members of class

  private:

      string day;

      double amtOfSale;

      int salesPersonId;

 //public methods

  public:

      //constructor that takes day,amount of sale and salesPersonId as parameters

      Sale(string date,double sale,int id)

      {

          //set the private members to the initial values passed

          day=date;

          amtOfSale=sale;

          salesPersonId=id;

      }    

      //declare a friend function that takes objects of the two classes as parameters

      friend void display(Sale,Salesperson);

};  

//define class Salesperson

class Salesperson

{

  //private members of the class

  private:

      int salesPersonId;

      string lastName;    

  //public methods

  public:

      //constructor that takes name and id as parameters

      Salesperson(int id,string name)

      {

          //set the members of the class with the parameters passed

          salesPersonId=id;

          lastName=name;

      }  

      //declare a friend function that takes objects of the two classes as parameters

      friend void display(Sale,Salesperson);

};

//define the friend funtion

void display(Sale saleObj,Salesperson personObj)

{

  //display the sales info using the objects of the two classes

  cout<<"\nSale #"<<saleObj.salesPersonId<<" on "<<saleObj.day<<" for $"<<saleObj.amtOfSale<<" sold by #"<<personObj.salesPersonId<<" "<<personObj.lastName;

}  

int main()

{

  //create object for Sale class and pass default values

  Sale sObj1("12/25/2016",559.95,103);

  //create object for Salesperson class and pass default values

  Salesperson pObj1(103,"Woods");

 

  //create another object for Sale class and pass default values

  Sale sObj2("11/15/2016",359.95,106);

  //create another object for Salesperson class and pass default values

  Salesperson pObj2(106,"Hansen");

  //using the friend function dislay the sales info

  display(sObj1,pObj1);

  display(sObj2,pObj2);

  return 0;

}

You might be interested in
List at least six things you would check for if you were asked to evaluate the workspace of an employee for ergonomics
Evgen [1.6K]

Assessing the risk that surrounds stationary work of employees spending hours at their stations is essential. Below is a list of fundamental ergonomic principles that help identify ergonomic risk factors.


<span>1.       </span>Are the employees maintained in a neutral posture?

<span>2.       </span>Does the stationery allow for movement and stretching?

<span>3.       </span>Is there adequate lighting?

<span>4.       </span>Are chairs adequately adjustable?

<span>5.       </span>Are there appropriate foot rest?

<span>6.       </span>Is there extra storage for better desk organization?






0 0
2 years ago
Write the 8-bit signed-magnitude, two's complement, and ones' complement representations for each decimal number: +25, + 120, +
pshichka [43]

Answer:

Let's convert the decimals into signed 8-bit binary numbers.

As we need to find the 8-bit magnitude, so write the powers at each bit.

      <u>Sign -bit</u> <u>64</u> <u>32</u> <u>16</u> <u>8</u> <u>4</u> <u>2</u> <u>1</u>

+25 - 0 0 0 1 1 0 0 1

+120- 0 1 1 1 1 0 0 0

+82 - 0 1 0 1 0 0 1       0

-42 - 1 0 1 0 1 0 1 0

-111 - 1 1 1 0 1 1 1 1

One’s Complements:  

+25 (00011001) – 11100110

+120(01111000) - 10000111

+82(01010010) - 10101101

-42(10101010) - 01010101

-111(11101111)- 00010000

Two’s Complements:  

+25 (00011001) – 11100110+1 = 11100111

+120(01111000) – 10000111+1 = 10001000

+82(01010010) – 10101101+1= 10101110

-42(10101010) – 01010101+1= 01010110

-111(11101111)- 00010000+1= 00010001

Explanation:

To find the 8-bit signed magnitude follow this process:

For +120

  • put 0 at Sign-bit as there is plus sign before 120.
  • Put 1 at the largest power of 2 near to 120 and less than 120, so put 1 at 64.
  • Subtract 64 from 120, i.e. 120-64 = 56.
  • Then put 1 at 32, as it is the nearest power of 2 of 56. Then 56-32=24.
  • Then put 1 at 16 and 24-16 = 8.
  • Now put 1 at 8. 8-8 = 0, so put 0 at all rest places.

To find one’s complement of a number 00011001, find 11111111 – 00011001 or put 0 in place each 1 and 1 in place of each 0., i.e., 11100110.

Now to find Two’s complement of a number, just do binary addition of the number with 1.

6 0
1 year ago
Given an array of ints named x and an int variable named total that has already been declared, write some code that places the s
Marizza181 [45]

Answer:

Following are the code:

Code:

total = 0; //assign value to total variable.

for (int i=0; i<x.length; i++) //for loop

{

total=total+x[i]; //add all array elements in total variable.

}

Explanation:

In the following question, it is defined that x and total is variable. Where variable x is an integer type array and total is an integer variable. we define some code for calculating the sum of the array element. In the above code, we use for loop that calculates sum of array elements that can be described as:

  • To calculate the sum we use the total variable. In total variable, we assign value 0.
  • Then we define for loop in loop we use total variables that add all array (x[]) elements.

8 0
1 year ago
Program documentation _____. Group of answer choices describes the inputs, outputs, and processing logic for all program modules
valentinak56 [21]

Answer:

In the given question the first line is correct, i.e. "Describes the inputs, outputs, and processing logic for all program modules".  

Explanation:

The documentation is a recorded text or image, which is preceding or in the code base of the programs, whether it describes how well the program works and how it is being used, and things in various positions can be influenced by people, and the wrong option can be described as follows:

  • In the documentation, it can't consist of rules and data.
  • In can't include a dictionary, flow maps, screen designs and device requests that began the program.
  • In can't provide links within the program.
6 0
2 years ago
Which of the following are recommended techniques for protecting computer files and data? Check all of the boxes that apply.
lara [203]
Hello <span>Pouerietzach


Question: </span><span>Which of the following are recommended techniques for protecting computer files and data? Check all of the boxes that apply.
</span><span>
Answer: A, B, D, E, G

Hope That Helps
-Chris</span>
5 0
2 years ago
Read 2 more answers
Other questions:
  • Which element of the word program window contains buttons for saving a document and for undoing, redoing, and repeating a change
    5·1 answer
  • What best describes the purpose of the Recycle Bin (Microsoft Windows) and Trash (Apple Mac) features
    13·2 answers
  • Suppose you develop an app and want to generate revenue but do not want to maintain the app. What would be your best choice?
    9·1 answer
  • In response to a recent outbreak of computer viruses, Babbage Industries, a large technology company, installs computer virus pr
    7·2 answers
  • Consider a DASH system for which there are N video versions (at N different rates and qualities) and N audio versions (at N diff
    8·1 answer
  • Assume the availability of class named IMath that provides a static method, toThePowerOf which accepts two int arguments and ret
    10·1 answer
  • The term that refers to the programmer reading the program from the beginning and stepping through each statement is _________.
    5·1 answer
  • Interpretations of​ Moore's law assert​ that:
    13·1 answer
  • While creating an animation, Gina has prepared a document stating the purpose and type of audience for the animation. What has
    6·1 answer
  • 12) Suppose you wanted a subroutine to return to an address that was 3 bytes higher in memory than the return address currently
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!