| | |
need help on corporate sales program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 18
Reputation:
Solved Threads: 0
Hi, I'm supposed to create a program that does the following:
A corporation has six divisions, each responsible for sales to different geographic locations. Design a divsales class that keeps the sales data for a division, with the following members:
an array with four elements 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 added to the static variable that holds the total yearly corporate sales.
A function that takes an integer arguments within the range of 0 to 3. The argument is to be sued as a subscript into the division quarterly sales array. the function should return the value of the array element with that subscript.
Write a program that creates an array of Six divSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data is entered, the program should display a table showing the division sales for each quarter. The pgoram should then display the total corporate sales for the year.
I have started working on the code but I can't seem to get the program to ask for 6 division sales ... my program only runs for 1 division and 4 quarters in that division... Also when the total amount is outputed, I get a bunch of garbage like 1N#aGO... etc , instead of a total number calculation.... Can someone show me how to get my code to accept 6 division sales and also how to fix my total amount so it shows the right number? Thank you.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
// 2d array with 3 rows and 4 columns for each division and quarter
float sales [3][4];
float totalSales = 0;
int div, qtr;
for (div = 0; div < 7; div++)
{ for (qtr = 0; qtr < 4; qtr++)
{
cout << "Please enter the sales for division " << (div + 1)
<< " Quarter " << (qtr + 1) << ": $";
cin >> sales[div][qtr];
cout << sales[div][qtr] << endl;
}
cout << endl;
for (div = 0; div < 7; div++)
{ for (qtr = 0; qtr < 4; qtr++)
totalSales += sales[div][qtr];
}
// Display the total
cout << "The total sales for the company are: $";
cout << totalSales << endl;
}
return 0;
}
A corporation has six divisions, each responsible for sales to different geographic locations. Design a divsales class that keeps the sales data for a division, with the following members:
an array with four elements 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 added to the static variable that holds the total yearly corporate sales.
A function that takes an integer arguments within the range of 0 to 3. The argument is to be sued as a subscript into the division quarterly sales array. the function should return the value of the array element with that subscript.
Write a program that creates an array of Six divSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data is entered, the program should display a table showing the division sales for each quarter. The pgoram should then display the total corporate sales for the year.
I have started working on the code but I can't seem to get the program to ask for 6 division sales ... my program only runs for 1 division and 4 quarters in that division... Also when the total amount is outputed, I get a bunch of garbage like 1N#aGO... etc , instead of a total number calculation.... Can someone show me how to get my code to accept 6 division sales and also how to fix my total amount so it shows the right number? Thank you.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
// 2d array with 3 rows and 4 columns for each division and quarter
float sales [3][4];
float totalSales = 0;
int div, qtr;
for (div = 0; div < 7; div++)
{ for (qtr = 0; qtr < 4; qtr++)
{
cout << "Please enter the sales for division " << (div + 1)
<< " Quarter " << (qtr + 1) << ": $";
cin >> sales[div][qtr];
cout << sales[div][qtr] << endl;
}
cout << endl;
for (div = 0; div < 7; div++)
{ for (qtr = 0; qtr < 4; qtr++)
totalSales += sales[div][qtr];
}
// Display the total
cout << "The total sales for the company are: $";
cout << totalSales << endl;
}
return 0;
}
![]() |
Similar Threads
- Lost - Pointers, Structs, Functions (C++)
- Java Developer Required (Software Development Job Offers)
- Function help/homework (C++)
- Help with flowcharts and pseudocodes (Visual Basic 4 / 5 / 6)
- Programing Final! (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: Need help With this C++ Program..Confused..
- Next Thread: need help on word counter
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





