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]
4 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]4 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
1. Insert a Header that has the following in excel​
Fofino [41]

Answer:

Go to Insert and click on Text and underneth that click header and footor.

Explanation:

You can do a Header and Fotter in Excel. ALl you have to do if go in the document you are working in and you click on Instert tab and then click on Header and Fotter. It gives you an option to make a header for your excel wookbook.

7 0
3 years ago
1. What are the biggest risks when using the public Internet as a Wide Area Network (WAN) or transport for remote access to your
enyata [817]

Answer:

The problems or risk when using a WiFi is that, hackers often have the ability to position themselves between the user and the end point connection. and once these hackers gains access to your information and privacy, u might lose important documents or contents.

It is of utmost importance that when an end user is using a public WiFi as a WAN, he/she must ensure to browse with VPN turned on, and the sharing options turned off.

Explanation:

Solution

One of the biggest risk with public WiFi is the ability or capacity for hackers to position themselves between you (user) and the point of connection. so instead of communicating directly with the hotpot, at several times you end up sending your information to the hacker.

The hacker also have access or privileges to every information you send out such as credit card information, emails and so on. once the hacker gains access to that information, you run into trouble.

As an end user when making use of public WiFi to ensure to browse with VPN (Virtual private Network) on and turned off sharing options

4 0
3 years ago
In 2-3 sentences, describe a case where circuit-switching is better than packet-switching?
cupoosta [38]
Because electricity powers everything , electricity can do anything
6 0
3 years ago
Computer network reduces the cost. explain the statement with example.​
Crank

Answer:

Justify this statement with an example. Ans: Computer Network reduces expenses of an office because computer on a network share different hardware devices like printers, scanners, hard disk etc. And sharing those hardware devicAes will reduces the expense of an office.

Explanation:

Justify this statement with an example. Ans: Computer Network reduces expenses of an office because computer on a network share different hardware devices like printers, scanners, hard disk etc. And sharing those hardware devicAes will reduces the expense of an office.

3 0
3 years ago
Describe the difference between fuses and circuit breakers. where might each type of device find its best use? g
ycow [4]
Here i found this link that might help!
https://study.com/academy/lesson/the-differences-between-fuses-circuit-breakers.html

Have a nice day!
3 0
4 years ago
Other questions:
  • I plugged my phone up into a charger, the charger sparked and i unplugged my phone and now it wont charge at all, does anyone kn
    13·1 answer
  • To begin importing data from an excel spreadsheet, click on the ____ tab on the ribbon.
    11·1 answer
  • The local emergency manager has the responsibility for coordinating emergency management programs and activities. A local emerge
    7·1 answer
  • Which of the following types of network can only be accessed by members within a private organization?
    5·1 answer
  • You can combine the algorithms for converting between infix to postfix and for evaluating postfix to evaluate an infix expressio
    13·1 answer
  • VOTE!
    11·1 answer
  • If your TV was showing a flat black or blue screen, or had "snow", what steps would you take to fix it?
    13·1 answer
  • Describe how a web browser and web server work together to send a web page to a user
    8·1 answer
  • 5.During a recent network attack, a hacker used rainbow tables to guess network passwords. Which type of attack occurred
    9·1 answer
  • Which of these is an example of collective voice?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!