Question

Write a complete C++ program that defines the following class: Class Salesperson { public: Salesperson( );...

Write a complete C++ program that defines the following class:
Class Salesperson
{
public:
Salesperson( ); // constructor
~Salesperson( ); // destructor
Salesperson(double q1, double q2, double q3, double q4); // constructor
void getsales( ); // Function to get 4 sales figures from user
void setsales( int quarter, double sales); // Function to set 1 of 4 quarterly sales
// figure. This function will be called
// from function getsales ( ) every time a
// user enters a sales figure. This function
// will also finds total annual sales.
void printsales( ); // This function will be called from main( ) function to print
// the total sale. Use formatted output to print the total sale up
// to two decimal digits as follows: The total annual sales are:
//$3679.67
void ReadFile( ); // Reads file “HW7_1.txt” and displays it on the //screen.
void EditFile( ); // Asks the user to enter a sentence (80 characters or less)
// to be added to the “HW7_1.txt” file.

private:
double sales [4]; // quarterly sales figures
};

Note:
1. You should implement each member function as a separate function and test your program with
the following main ( ) function.
2. Your class definition and declaration must be in separate files. (Note: Class declaration is in a
file with “.h” extension; whereas Class member function definitions are in a file with same name
as class declaration name, but extension “.cpp”)
3. You should also provide a constructor that can accept argument to initialize the array sales.
4. Include a destructor as well.
5. Using a text editor, create two text files called HW7_1.txt and HW7_2.txt. Each file should
contain five (5) different one-line (80 characters or less) sentences.
6. void EditFile(string filename ) function should also create a third file (HW7_3.txt) consisting of
the contents of file HW7_1.txt plus a sentence entered by the user. Repeat this step as many
Assigned:
November 15, 2018
Due Date:
December 2, 2018
times as the user desires.
7. Next, void EditFile(string filename ) function should merge files HW7_2.txt and HW7_3.txt
into a fourth file (HW7_4.txt).
The input files HW7_2.txt and HW7_3.txt should not be of the same length at this point.
8. In the main( ), print the contents of files HW7_2.txt, HW7_3.txt, and HW7_4.txt; and a count
of the letters in each file.

int main ( )
{
Salesperson s, z(a, b, c, d); //values a, b, c, and d are set by the user using cout/cin.
s.getsales( );
s.printsales( );
z.printsales( );
z.ReadFile( );
z.EditFile( );
return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Write a complete C++ program that defines the following class: Class Salesperson { public: Salesperson( );...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • It is a C++ program by using inheritance and vectors My professor said that all the files should be separate. like File.cpp, File.h, Text.cpp,Text.h,Main.cpp I already have these files File.cpp #inclu...

    It is a C++ program by using inheritance and vectors My professor said that all the files should be separate. like File.cpp, File.h, Text.cpp,Text.h,Main.cpp I already have these files File.cpp #include "File.h" // Constructor of File that takes File name and type as arguments File::File(string type, string name) {    this->type = type;    this->name = name; } //returns the type. string File::getType() {    return type; } //returns the name of file. string File::getName() {    return name; } File.h #ifndef __FILE_H__ #define...

  • 4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java...

    4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...

  • Help. Write a C++ program that determines which of a company's four divisions (North, South, East,...

    Help. Write a C++ program that determines which of a company's four divisions (North, South, East, West) has the greatest sales for the quarter. It should include three functions at a minimum: float getSales() is passed the name of a division. It asks the user for a division's quarterly sales figure, calls a validate() function that will validate the input, and then returns the value back to main(). This function should be called once for each division. void validate() is...

  • The code should be written in C++. I included the Class used for this function. Also,...

    The code should be written in C++. I included the Class used for this function. Also, please fix the main function if necessary. Description: This function de-allocates all memory allocated to INV. This will be the last function to be called (automatically by the compiler) //before the program is exited. This function also erased all data in the data file. There are other functions that add, process and alter the file; the file printed after those functions will have new...

  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • The class declaration (interface) and the function definitions (implementation) must be in separate files - the...

    The class declaration (interface) and the function definitions (implementation) must be in separate files - the interface or "header" file has a .hpp extension and the implementation has a .cpp extension. As usual, all data members should be private. Write a class called BankAccount that has: a string data member called customerName, a string data member called customerID, and a double data member called customerBalance a constructor that takes two strings and a double (name, ID, balance) and uses them...

  • In c++ Write a program that contains a class called Player. This class should contain two...

    In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class...

    please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...

  • please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits...

    please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits from File and is a non-abstract class. 1. Hence objects of the class JPG can be instantiated. 2. To do so, we must override the pure virtual function clone() in the base class. • The class declaration is given below. class JPG : public File { public: JPG(const std::string& n, int n, int w, const double rgb()) : File(...) { // ... } *JPG()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT