Concept explainers
Corporate Sales
A corporation has six divisions, each responsible for sales to different geographic locations. Design a DivSales class that keeps sales data for a division, with the following members:
• An array with four elements for holding four quarters of sales figures for the division.
• A private static variable for holding the total corporate sales for all divisions for the entire year.
• A member function that takes four arguments, each assumed to be the sales for a quarter. The value of the arguments should be copied into the array that holds the sales data. The total of the four arguments should be added to the static variable that holds the total yearly corporate sales.
• A function that takes an integer argument within the range of 0-3. The argument is to be used as a subscript into the division quarterly sales array. The function should return the value of the array element with that subscript.
Write a
Input Validation: Only accept positive values for quarterly sales figures.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
C Programming Language
Java How To Program (Early Objects)
Starting Out with C++: Early Objects
Modern Database Management
Problem Solving with C++ (10th Edition)
- C++ Design a class called bowler that stores data about a participant in a bowling tournament. For each bowler,the following information should be tracked: first name, last name, three bowling scores, and an average score.Valid bowling scores are in the range of 0-300. Include appropriate constructors, mutators, and accessors.Overload the ==, <, and > operators to compare the average score of one bowler's record to another.Once you have designed your class, implement an array that can store up to 25 bowler records. An indexshould be included to keep track of how many bowler records have been entered.Include an insertionSort routine to sort the bowler records. (Hint: If you overload the ==, <, and >operators, a standard insertionSort will work. However, you will need to revise the algorithm to sort fromhighest to lowest.)Implement a menu system that implements options to add a bowler to the list and print a complete list ofbowlers in the array sorted by bowling average…arrow_forwardTic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed. (programming language C#)arrow_forward(Tic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.arrow_forward
- C++ (Tic-Tac-Toe) Write a program that allows two players to play the tic- tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.arrow_forwardA corporation has six divisions, each responsible for sales of different geographic locations. The DivSales class holds the quarterly sales data for one division. Complete the DivSales class which keeps sales data for one division, with the following members: sales - a private array with four elements of type double for holding four quarters of sales figures for one division. (Note this is not a dynamic array). This is provided. totalSales - a private static variable of type double for holding the total corporate sales for all the divisions (every instance of DivSales) for the entire year. a default constructor that sets all the quarters to 0 . This is provided. setSales - a member function that takes four arguments of type double, each assumed to be the sales for one quarter. The value of each argument should be copied into the private sales array. The total of the four arguments should be added to the static variable totalSales that holds the total yearly corporate sales. If a…arrow_forward(Rectangle Class) Create a class Rectangle with attributes length and width, each of whichdefaults to 1. Provide member functions that calculate the perimeter and the area of the rectangle.Also, provide set and get functions for the length and width attributes. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.arrow_forward
- The class has attributes length and width, each of which defaults to 1.b.It should have member functions that calculate the perimeter and area of the rectangle.c.It should have set and get functions for both length and width.d.The set functions should verify that length and width are each floating-point number larger than 0.0 and less than 20.0.arrow_forwardThe program has to be in c++ Write a receipt class that simulates the receipts received in the store in a simplified form. Class to contain as data members• The name of the store• Array of prices of purchased goods and member functions: Constructors get () and set () - for prices to work with individual elements of the array show () - displays a list of prices, the goods to be named product # 1, product # 2, etc. total () - determines the total price of the goods remove () - removes a product from the list (according to its index) discount () - reduces the price of goods by a certain percentage (the index of the goods in the array and the percentage are submitted as parameters) other member functions if desired In the main function, illustrate how to work with the methods of the receipt class.arrow_forwardc++ Write a class named TestScores. The class constructor should accept an array of test scores as itsargument. The class should have a member function that returns the average of the test scores. If any testscore in an array is negative or greater than 100 it should display a message.arrow_forward
- 1. Define a struct for a soccer player that stores their name, jersey number, and total points scored. 2. Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the average number of points scored by the players.3. Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the index of the player who scored the most points.4. Write a Circle class that has the following member variables:• radius : a double• pi : a double initialized with the value 3.14159The class should have the following member functions:• Default Constructor. A default constructor that sets radius to 0.0.• Constructor. Accepts the radius of the circle as an argument.• setRadius. A mutator function for the radius variable.• getRadius. An accessor function for the radius variable.• getArea. Returns the area of the circle, which is calculated as area = pi * radius * radius• getCircumference. Returns…arrow_forward1- A complex number has the form a+bi , can be expressed as theordered pair of real numbers (a,b). The class represents the real andimaginary parts as double precision values.Provide a constructor that enables an object of this class to beinitialized when it is instantiated. The constructor should containdefault values.Provide Public member functions for each of the followingarithmetic’s functions (addition – subtraction – multiplication –division), a complex absolute value operation, printing the number inthe form (a,b), printing the real part , printing the imaginary part andfinal overload the == operator to allow comparisons of two complexnumbers.Include any additional operations that you think would be useful fora complex number class.Design, implement, and test your class.arrow_forwardClass student contains roll number, name and course as data members and Input_studentand display_student as member functions. Create a class exam and publicly inherit it fromstudent class. The derived class contains an array of marks and no_of_subjects as datamembers, and input_marks and display_result as member functions. Overload “<=”, “()” and“+=” operators and use the overloaded operators in the main function. Create an array ofobjects of the exam class and display the result of 5 studentarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning