need help on corporate sales program

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: Sep 2004
Posts: 18
Reputation: wangstarr is an unknown quantity at this point 
Solved Threads: 0
wangstarr wangstarr is offline Offline
Newbie Poster

need help on corporate sales program

 
0
  #1
Dec 2nd, 2004
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;
}
Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: need help on corporate sales program

 
0
  #2
Dec 2nd, 2004
You're not following your instructions.
Where is your class?
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC