Question

In: Computer Science

Write a program that uses a structure to store the following data on a company division...

Write a program that uses a structure to store the following data on a company division in c++

  • Division Name (such as East, West, North, or South)
  • First-Quarter Sales
  • Second-Quarter Sales
  • Third-Quarter Sales
  • Fourth-Quarter Sales
  • Total Annual Sales
  • Average Quarterly Sales

The program should use four variables of this structure. Each variable should represent one of the following corporate divisions: East, West, North, and South. The user should be asked for the four quarters’ sales figures for each division. Each division’s total and average sales should be calculated and stored in the appropriate member of each structure variable. These figures should then be displayed on the screen.

Input Validation: Do not accept negative numbers for any sales figures.

Solutions

Expert Solution

If you have any doubts, please give me comment...

#include <iostream>

#include <string>

using namespace std;

struct Division

{

string division_name;

double first_quarter_sales;

double second_quarter_sales;

double third_quarter_sales;

double fourth_quarter_sales;

double total_sales;

double avg_quarter_sales;

};

double getSales();

int main()

{

Division division;

cout << "Enter division name: ";

cin >> division.division_name;

cout << "First Quarter sales: ";

division.first_quarter_sales = getSales();

cout << "Second Quarter sales: ";

division.second_quarter_sales = getSales();

cout << "Third Quarter sales: ";

division.third_quarter_sales = getSales();

cout << "Fourth Quarter sales: ";

division.fourth_quarter_sales = getSales();

division.total_sales = division.first_quarter_sales + division.second_quarter_sales + division.third_quarter_sales + division.fourth_quarter_sales;

division.avg_quarter_sales = division.total_sales / 4;

cout << "Sales Report: ";

cout << "Division Name: " << division.division_name << endl;

cout << "First Quarter Sales: " << division.first_quarter_sales << endl;

cout << "Second Quarter Sales: " << division.second_quarter_sales << endl;

cout << "Third Quarter Sales: " << division.third_quarter_sales << endl;

cout << "Fourth Quarter Sales: " << division.fourth_quarter_sales << endl;

cout << "\nTotal Annual Sales: " << division.total_sales << endl;

cout << "Average Quarterly Sales: " << division.avg_quarter_sales << endl;

return 0;

}

double getSales()

{

double sales;

cin >> sales;

while (sales < 0)

{

cout << "Sales must be positive. Reenter: ";

cin >> sales;

}

return sales;

}


Related Solutions

Write a program that uses a structure to store the following weather data for a particular...
Write a program that uses a structure to store the following weather data for a particular month: Total Rainfall High Temperature Low Temperature Average Temperature. The program should have an array of 12 structures to hold weather data for an entire year. When the program runs, it should ask the user to enter data for each month. (The average temperature should be calculated.) Once the data are entered for all the months, the program should calculate and display the average...
Write a program that uses a structure to store the following data: (Remember to use proper...
Write a program that uses a structure to store the following data: (Remember to use proper formatting and code documentation) Member Name Description name student name idnum Student ID number Scores [NUM_TESTS] an array of test scores Average Average test score Grade Course grade Declare a global const directly above the struct declaration const int NUM_TESTS = 4; //a global constant The program should ask the user how many students there are and should then dynamically allocate an array of...
Write a program that uses a structure to store the following data about a customer account:...
Write a program that uses a structure to store the following data about a customer account: Name Address City, State and Zip Telephone number Account balance Date of last payment The program should use an array of at least 5 structures. It should let the user enter data into the array, change the contents of any element and display all the data stored in the array. The program should have a menu-driven interface and use functions as appropriate. Input validation:...
11.7: Customer Accounts Write a program that uses a structure to store the following data about...
11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Prompts And...
C++ 11.7: Customer Accounts Write a program that uses a structure to store the following data...
C++ 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account: Customer name Customer address City State ZIP code Telephone Account balance Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Prompts...
Write a program that does the following in C++ 1 ) Write the following store data...
Write a program that does the following in C++ 1 ) Write the following store data to a file (should be in main) DC Tourism Expenses 100.20 Revenue 200.50 Maryland Tourism Expenses 150.33 Revenue 210.33 Virginia Tourism Expenses 140.00 Revenue 230.00 2 ) Print the following heading: (should be in heading function) Store name | Profit [Note: use setw to make sure all your columns line up properly] 3 ) Read the store data for one store (should be in...
Write a program for a beauty store that uses an InputBox to ask the guest for...
Write a program for a beauty store that uses an InputBox to ask the guest for a membership code. Embed this in a Do loop so that the user has to keep trying until the result is a valid membership code that starts with “Beauty” (case insensitive) and is followed by 4 digits with the final digit equal to either 6 or 8. Then use a message box to display the input promotion code and inform the user that the...
Write a C program that will read different data types from the following file and store...
Write a C program that will read different data types from the following file and store it in the array of structures. Given file: (This file have more than 1000 lines of similar data): time latitude longitude depth mag magType nst gap dmin 2020-10-19T23:28:33.400Z 61.342 -147.3997 12.3 1.6 ml 12 84 0.00021 2020-10-19T23:26:49.460Z 38.838501 -122.82684 1.54 0.57 md 11 81 0.006757 2020-10-19T23:17:28.720Z 35.0501667 -117.6545 0.29 1.51 ml 17 77 0.1205 2020-10-19T22:47:44.770Z 38.187 -117.7385 10.8 1.5 ml 15 100.22 0.049 2020-10-19T22:42:26.224Z...
Write a program that uses the defined structure and all the above functions. Suppose that the...
Write a program that uses the defined structure and all the above functions. Suppose that the class has 20 students. Use an array of 20 components of type studentType. Other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the...
Write a program to implement linked list data structure that will have following functions: a. Append...
Write a program to implement linked list data structure that will have following functions: a. Append a node in the list b. Insert a node in the list c. Delete a node from the list d. Display list e. Find maximum value in the list f. Find how many times a value exists in the list. g. Search Portion of the code is give below. You have to write code for the items (e, f, g) Program: #include<stdlib.h> #include<stdio.h> #include<iostream>...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT