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 happens when a user updates a record after a developer creates a Workflow Rule declaratively that updates a field on an obj
Sindrei [870]

Answer:

d. The trigger is fired more than once.

Explanation:

What would happen in this situation is that the  trigger would be fired more than once. This is because the trigger will be fired when the user updates the record. It will also be fired when the process builder is run.

If the trigger fires more than once, this can be problematic for the developer. Therefore, it is better if the trigger fires just once, as this is the time when the present changes can be placed.

5 0
2 years ago
Which task is a part of the analysis phase of the SDLC
eduard
Following are the seven phases of the SDLC:Planning (1), Systems Analysis (2), Systems Design (3), Development (4), Testing (5), Implementation (6) and Maintenance (7)
8 0
2 years ago
Read 2 more answers
Name of main component of fifth generation of computer​
e-lub [12.9K]

Answer:In the fifth generation, VLSI technology became ULSI (Ultra Large Scale Integration) technology, resulting in the production of microprocessor chips having ten million electronic components. This generation is based on parallel processing hardware and AI (Artificial Intelligence) software.

Explanation: hope this helps ❤️

3 0
3 years ago
What are the differences between switches and routers? cse question
deff fn [24]

Answer:

The main objective of router is to connect various networks simultaneously and it works in network layer

Explanation:

The main objective of router is to connect various networks simultaneously and it works in network layer

7 0
2 years ago
What is machine level language ?​
NeX [460]

Answer:

The machine-level language is a language that consists of a set of instructions that are in the binary form 0 or 1.

5 0
2 years ago
Other questions:
  • In older systems, often the user interface mainly consisted of ____-control screens that allowed a user to send commands to the
    11·1 answer
  • Which best describe a resource each student could use to find information
    6·2 answers
  • You are going to write a program for Computer test which will read 10 multiple choice questions from a file, order them randomly
    11·1 answer
  • What technique can improve web search results? Add articles, prepositions, and pronouns Be general rather than specific Focus on
    10·1 answer
  • What is an identified component of a software program that might allow a hacker or other intruder to gain entry and control of a
    10·2 answers
  • Employees at the Red Bluff Golf Club &amp; Pro Shop have the opportunity to become certified trainers if they log enough hours.
    13·1 answer
  • Analyze the following code. Which of the following statements is correct?
    9·1 answer
  • write a script to check command arguments. Display the argument one by one (use a for loop). If there is no argument provided, r
    6·1 answer
  • Moving your Sprite from right to left is considered the X coordinate?
    5·1 answer
  • The create_python_script function creates a new python script in the current working directory, adds the line of comments to it
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!