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
Elina [12.6K]
3 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]3 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
What is the output of the following code:
Zielflug [23.3K]

Answer:

Explanation:

print(list1)

['C++', 'JAVA', 'ASP.PHP']

[2:-2]

Gets 2 position(C++) to -2 position(ASP.PHP), JAVA is in the Middle

print(list2)

[]

Gets middle of C++(nothing)

print(list3)

['Python', 'JAVA', 'MySQL']

Get first, jump 3, get first...

'get', 'any', 'any', 'get', 'any', 'any', 'get', ...

7 0
2 years ago
I need help with the code practice 9.2 Edhesive.<br><br> Thank you
antiseptic1488 [7]

Answer:

you talking about anaconda navigation? i would love to help!

Explanation:

3 0
3 years ago
Read 2 more answers
Write a demo test to verify the above Rectangle object accessible from demo test main program and can execute display() method t
Sati [7]

Answer:

Explanation:

The Rectangle class was not provided in this question but after a quick online search I was able to find the class code. Due to this I was able to create a test code in the main Method of my program to create a Rectangle object and call it's display() method. The Test code and the output can be seen in the attached image below. While the code below is simply the Main Test Program as requested.

class Brainly {  

   public static void main(String[] args) {

       Rectangle rectangle = new Rectangle(20, 8);

       rectangle.display();

   }

}

4 0
2 years ago
______ behavior expected from every professional​
Shalnov [3]

Answer:

Respectful

Explanation:

3 0
2 years ago
Meaning of sperm count
yulyashka [42]

a measure of the number of spermatozoa per ejaculation or per measured amount of semen, used as an indication of a man's fertility.


5 0
2 years ago
Read 2 more answers
Other questions:
  • A(n)________________ is something that goes into a system a resource such as time,money,communication,etc
    10·1 answer
  • ​What file system below does not support encryption, file based compression, and disk quotas, but does support extremely large v
    10·1 answer
  • How to use javascript libraries in javascript code?
    9·1 answer
  • Crashing almost always accelerates the schedule while increasing project risk, whereas fast tracking almost always accelerates t
    10·1 answer
  • Timeliness is an important goal of any access control monitoring system.<br> A. True<br> B. False
    9·1 answer
  • Which of the following is not a shared characteristic of new media.
    8·1 answer
  • A(n) _____ access file is also known as a direct access file.
    13·1 answer
  • 1. asynchronous_communication
    5·1 answer
  • Apps are designed by___.
    11·2 answers
  • Who plays warzone im a roze sweat and ill try to carry with loadout
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!