944,149 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4186
  • C++ RSS
Dec 2nd, 2004
0

need help on corporate sales program

Expand Post »
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;
}
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
wangstarr is offline Offline
18 posts
since Sep 2004
Dec 2nd, 2004
0

Re: need help on corporate sales program

You're not following your instructions.
Where is your class?
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: need help with arrays
Next Thread in C++ Forum Timeline: need help on word counter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC