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
Which tables and fields would you access to determine which book titles have been purchased by a customer and when the order shi
enyata [817]

Answer:

To determine which book titles have been purchased by a customer and when the order shipped the following tables and fields would be used.

Table:      

  • CUSTOMERS

Fields

  • Customerno

Table

  • ORDERS

Fields:

  • Orderno
  • Shipdate
  • Customerno

Table:

  • ORDERITEMS

Fields:

  • Orderno

Table:

  • BOOKS

Fields

  • isbn
  • title

BOOKS table contains field like title of the books, so this will help in finding which book titles have been purchased.

CUSTOMERS table keeps information about customers that purchasing an ordering the books. The customerno uniquely identifies each customer so that the order information can be found using the customerno of a specific customer.

ORDERITEMS keeps information about orders via orderno

ORDERS table will keep track about the shipment of orders. Orderno identifies each order, shipdate will help determine when an order is shipped.

7 0
3 years ago
E) Point out the errors( if any) and correct them:-
leonid [27]

Explanation:

double e-d/5.6;is wrong it should return to c

5 0
2 years ago
Draw a flowchart diagram for a program that displays numbers 1 to 20
madreJ [45]
Here you go plz mark brainlist
6 0
2 years ago
Environmental technology examples
meriva

Exhaust Gas Recirculation (EGR) for NOx control
<span>Positive Crankcase Ventilation (PCV) for HC emission control </span>
Evaporative Emissions Control(EVAP)
<span>Catalytic Converter for HC and NOx control</span>
6 0
3 years ago
Which is the most used operating system? A. Windows B.Linux C.Leopard D. DOS
Neko [114]
I think it´s either A. or  B.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that asks the user to input four numbers (one at a time). After the four numbers have been supplied, it should t
    6·1 answer
  • Minimalism is a major movement in postmodern art. O True O False
    14·1 answer
  • Which is the correct formula to add the values in cells A1 and B1?
    11·2 answers
  • Georgenotfound??? question mark??
    15·2 answers
  • -The following type of Access form allows to see multiple records in an Excel-like arrangement of data fields:
    14·1 answer
  • 1)Which of the following statements about the print statement are TRUE? (Check all that apply)
    8·1 answer
  • To whom the script most important
    13·1 answer
  • Most network behavior analysis system sensors can be deployed in __________ mode only, using the same connection methods as netw
    8·1 answer
  • In addition to assuming that n is a power of 2, we made, for the sake of simplicity, another, more subtle, assumption in setting
    5·1 answer
  • What permissions are needed in order to use a work online that is in the public domain?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!