Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview For this assignment, implement and use the methods for a class called Seller that represents information about a salesperson. The Seller class Use the

Overview

For this assignment, implement and use the methods for a class called Seller that represents information about a salesperson.

The Seller class

Use the following class definition:

class Seller { public: Seller(); Seller( const char [], const char[], const char [], double ); void print(); void setFirstName( const char [] ); void setLastName( const char [] ); void setID( const char [] ); void setSalesTotal( double ); double getSalesTotal(); private: char firstName[20]; char lastName[30]; char ID[7]; double salesTotal; }; 

Data Members

The data members for the class are:

firstName this holds the Seller's first name

lastName this holds the Seller's last name

ID this holds the Seller's id number

salesTotal this holds the Seller's sales total

Constructors

This class has two constructors. The default constructor (the one that takes no arguments) should call the various set methods to initialize the first and last names to "None", the seller ID to "ZZZ000", and the sales total to 0.

The other constructor for the class should initialize the data members using the passed in arguments. It takes 4 arguments: a character array with a Seller's first name, a character array with a Seller's last name, a character array with a Seller's id number, and a double that holds the Seller's sales total. As with the previous constructor, the data members should be initialized by calling the various set methods.

Methods

void print()

This method displays the Seller information. It takes no arguments and returns nothing.

The information should be displayed as follows:

Giant, Andre BIG357 678.53 

void setFirstName( const char newFirstName[] )

This method changes a Seller's first name. It takes one argument: an array of characters that represents the Seller's first name. It returns nothing.

If the length of newFirstName is greater than 0, it should be used to initialize the firstName data member. Otherwise, the firstName data member should be set to "None". For example:

if( strlen( newFirstName ) > 0 ) { strcpy( firstName, newFirstName ); } else { strcpy( firstName, "None" ); } 

void setLastName( const char newLastName[] )

This method changes a Seller's last name. It takes one argument: an array of characters that represents the Seller's last name. It returns nothing.

If the length of newLastName is greater than 0, it should be used to initialize the lastName data member. Otherwise, the lastName data member should be set to "None".

void setID( const char newID[] )

This method changes a Seller's id number. It takes one argument: an array of characters that represents the Seller's id number. It returns nothing.

If the length of newID is greater than 0 and less than 7, it should be used to initialize the ID data member. Otherwise, the ID data member should be set to "ZZZ000".

void setSalesTotal( double newSalesTotal )

This method changes a Seller's sales total. It takes one argument: a double that represents the Seller's sales total. It returns nothing.

If the passed in newSalesTotal is greater than or equal to 0, it should be used to initialize the salesTotal data member. Otherwise, the salesTotal data member should be set to 0.

double getSalesTotal(

This method returns a Seller's sales total data member. It takes no arguments.

main()

In main(), create 5 Seller objects. They should contain the values:

The first Seller should have your name, an id of "CSI240", and a sales total of 1234.56. Note: if you're pair programming, set the first name to the first name of both you and your partner: "Jane/John" and the last name to the last name of both you and your partner: "Doe/Doe".

The second Seller should be created using the default constructor (the one that doesn't take any arguments)

The third Seller should have the first name of an empty string (""), a last name of "Johnson", an id of "TOOBIG999", and a sales total 876.34.

The fourth Seller should have the name "James Hellwig", an id of "ULTWAR", and a sales total of 13579.11

The fifth Seller should have the name "Roderick Toombs", an id of "PIPER4", and a sales total of 24680.24

The rest of main() will include using the various methods on each of the 5 Seller objects. Display a label similar to "The first Seller object" before anything is outputted for each of the objects.

For the first Seller, display the Seller information.

For the second Seller, display the Seller information, set the Seller name to "Terry Bollea", set the id number to "HULK96", set the sales total to 246.80, and then display the Seller information once again.

For the third Seller, display the Seller's information, set the Seller's first name to "Dwayne", set the id number to "ROCK89", and then display the Seller information once again.

For the fourth Seller, display only the Seller's sales total.

For the fifth Seller, display the Seller's information, set the first name to an empty string (""), set the last name to an empty string, set the id number to an empty string, set the sales total to -19.88, and then display the Seller information once again.

Programming Notes

Each method must have a documentation box like a function.

Hand in a copy of your source code using Blackboard.

Output

Note: The information for the first Seller object will have your name.

*** The first Seller object *** Doe, Jane CSI240 $1234.56 *** The second Seller object *** None, None ZZZ000 $0.00 Bollea, Terry HULK96 $246.80 *** The third Seller object *** Johnson, None ZZZ000 $876.34 Johnson, Dwayne ROCK89 $876.34 *** The fourth Seller object *** Sales total is $13579.11 *** The fifth Seller object *** Toombs, Roderick PIPER4 $24680.24 None, None ZZZ000 $0.00 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Write a program in C + + to print the first 2 0 prime numbers.

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago