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
Which would increase electric current? increasing the resistance increasing the size of the wire decreasing the voltage
Neko [114]
The answer is the second answer Increasing the size of the wire.
8 0
3 years ago
How to represent derived attributes in database?
Vlad1618 [11]

Answer:

Derived attribute can be defined as a type of attribute where its value will be derived from one or more of the other attributes of the same entity set.

Explanation:

An example of derived attribute is when we have an entity set called General. The set then has attributes like [Form], [Characteristics], [Address}, (Employment No).

(Employment No) which is represented distinctly in the attribute set can be called a derived attribute if it can be derived from one or more of the other attributes.

Derived attribute can be gotten through calculating values and not storing values.

For example, let us consider the following record of Teachers records;

(‘Teacher Number’, ‘Name’, ’Date of Birth’, Age today)

(‘E105’, ‘Samson’, ’07-Dec-1990’, 0)

This record shows that the teacher Samson was born on 7th of December, 1990. At the time of record insertion, he was born and 0 years old. What will be the value of his age on ’07-Dec-2000’? It is about 10 years. It clearly shows that the value is not fixed and it is a variable whenever the DOB is adjusted.

Therefore, we are not creating our table with derived attributes in it. Instead, the values ofderived attributes can be calculated at the time of retrieval and shown to the user. Hence, the record will look like as follows;

(‘E105’, ‘Samson’, ’07-Dec-1990’)

This means that 0 is a derived attribute from the Date of birth.

7 0
3 years ago
​___________ contain microprocessors and tiny antennas that allow them to​ receive, store, and transmit​ data, such as the locat
Gwar [14]

Answer:

The correct option is C: Radio frequency identification tags

Explanation:

Radio frequency identification tags also known as RFID tags involves the use of radio waves to​ receive, store, and transmit​ data which are usually stored on a tag that is attached to an object. A tag contains microprocessors and tiny antennas and whether it is in line of sight or not, it can be tracked and information transmitted from it.

4 0
3 years ago
The __________ method can determine whether a string contains a value that can be converted to a specific data type before it is
luda_lava [24]

Answer:

tryparse method

Explanation:

You can convert a string to a number by calling the TryParse method found on various numeric types (int, long, double, etc.), or by using methods in the System.Convert class.

8 0
3 years ago
Please give all the answer​
il63 [147K]

Answer:

am/is=was

are=were

do=did

go=went

eat=ate

have=had

make=made

take=took

see=saw

fly=flew

sell=sold

tell=told

find=found

sent=sent

Explanation:

These are all present/ past tense

I hope this helps.

5 0
3 years ago
Read 2 more answers
Other questions:
  • How do particles move at higher temperatures compared to how they move at lower temperatures?
    10·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    8·1 answer
  • You are the administrator for a small company. You need to create a new group for users in the sales department. You need to nam
    14·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • what programs controls all operations of the computer hardware such as memory storage devices or printers and provides for you t
    7·1 answer
  • What are the most positive and the most negative decimal numbers that can be represented by a 2C (n+k) bit fixed-point number, w
    12·1 answer
  • Explain the applications software that you use everyday
    5·1 answer
  • This is your code.
    9·1 answer
  • How to follow accounts on brainy
    11·1 answer
  • "You have created a Word document named apple.docx using Microsoft Word. What type of a file is apple.docx ? Select all that app
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!