User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,573 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,583 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 733 | Replies: 14
Reply
Join Date: Oct 2007
Posts: 5
Reputation: danielle2 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danielle2 danielle2 is offline Offline
Newbie Poster

quaterly sales statistics

  #1  
Oct 29th, 2007
I have been given a problem that asks me to do the following things. Write a program should be stored in two dimensional array. The program must include the following
1. list 4 qtrly sales for 6 divisions of a company.
2. show each division increase or decrease from the previous qtr
3. total the sales for the qtr
4. show the companys increase or decrease from previous qtr...excluding the first qtr.
5. average sales for all divisions that qtr
6. list the division with the highest sales for that qtr.

**now I understand that this is just a site that offers assistance with problems and I must be willing to work as well...so this is what I know...
that the firs size declarator would pertain to the number of rows and the second one is for the number of columns. I also know and understand that a two dimensional array has 2 subscripts...but it all gets a little mirky after that...please help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #2  
Oct 29th, 2007
You're absoluately right. We won't give you a complete code, but we'll help and provide pointers. Firstly, welcome aboard. I can give you a head start, although i wish you'd read up on arrays. You need to tell us if the program is doing to be interactive, will it read data from the infile???
A few things:
1. You can start by delcaring a few variables that you'll need:
struct Comp;
float first;
float second;
float third;
float value;
float average;
2. With regards to the six divisions...for example, if it's the same company, they perhaps are divided as such:
string const N = "North Division";
string const S = "South Division";
string const E = "East Division";
string const W = "West Division";
3. Then for the arrays, you may do something like:
	Comp div[4]

	div [0].name= N;
	div [1].name= S;
	div [2].name= E;
	div [3].name= W;
4. Create a titles/headers to show your output data:
cout<<setw(10)<<"Division"<<setw(15)<<"First Quarter"<<setw(15)<<"Second Quarter"<<setw(15)<<"Third Quarter"<<setw(15)<<"Fourth Quarter"<<setw(15)<<"Total"<<setw(15)<<"Average"<<endl;
5. Use a FOR loop to go through each division.
6. Do calculation to carry out the averages.
Hope this helps, I know that C++ at times may be overwhelming, but write it out on scratch-paper first to see exactly what you'll need to do. I gave you a jumpstart. You'll also need to provide more information about the requirements of your assignment.
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #3  
Oct 29th, 2007
In other words....can you please post what you've got so far?
Reply With Quote  
Join Date: Oct 2007
Posts: 5
Reputation: danielle2 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danielle2 danielle2 is offline Offline
Newbie Poster

Re: quaterly sales statistics

  #4  
Oct 29th, 2007
this is what I have so far

1 //This program demonstrates a two-dimensional array.
2 #include <iostream>
3 #include <iomanip>
4 using name space std;
5
6 int main()
7 {
8 const int NUM_DIVS=6; //Number of divisions
9 const int NUM_QTRS =4; //Number or quaters
10 double sales [NUM_DIVS] [NUM_QTRS]; //Array with 6 rows and 4 columns.
11 double totalSales = 0; //To hold the total sales.
12 int div, qtr; // Loop counters.
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #5  
Oct 29th, 2007
Please format your code:
At the begining of your code place:
"["CODE=cplusplus"]"
PLACE CODE HERE
At the end of your code, place "["/CODE"]"...without the "
Last edited by zandiago : Oct 29th, 2007 at 3:32 pm.
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #6  
Oct 29th, 2007
11 double totalSales = 0; //To hold the total sales.
This is to calculate Total sales...not to store it.
2.Where are the headers/titles i pointed out in my previous post? Where is your loops? You've still got quite a bit of work...
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #7  
Oct 29th, 2007
You'll also need the following header for mathematical calculations(averages..ect...)
#include <cmath>
Reply With Quote  
Join Date: Oct 2007
Posts: 5
Reputation: danielle2 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danielle2 danielle2 is offline Offline
Newbie Poster

Re: quaterly sales statistics

  #8  
Oct 29th, 2007
1 //This program demonstrates a two-dimensional array.
2 #include <iostream>
3 #include <iomanip>
4 #include <cmath>
5 using name space std;
6 int main()
7 {
8 const int NUM_DIVS=6; //Number of divisions
9 const int NUM_QTRS =4; //Number or quaters
10 double sales [NUM_DIVS] [NUM_QTRS]; //Array with 6 rows and 4 columns.
11 double totalSales = 0; //To calculate the total sales.
12 int div, qtr; // Loop counters.
13
14 cout <<"This program will calculate the total sales of \n";
15 cout<<"all th4e company's divisions.\n";
16 cout <<"Enter the following sales information:\\n\n";
17
18 //Nested loops to fill the array with quaterly
19 //sales figures for each division
20 for (div = 0 ; div< NUM_DIVS; div++)
{
[/code][/quote]
Reply With Quote  
Join Date: Jun 2007
Location: Home
Posts: 2,451
Reputation: zandiago is on a distinguished road 
Rep Power: 6
Solved Threads: 24
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: quaterly sales statistics

  #9  
Oct 29th, 2007
At the begining of your code place:
"["CODE=cplusplus"]", without the ". This way its easier to read...back to your assignment....
16 cout <<"Enter the following sales information:\\n\n";
Given the requirement of your assignment, you may want to break down your program a bit more...example:
  1. cout<< "Please enter First Qrt Sales"<<div[j].name<<endl;
  2. cin>>div[j].fir;
  3. cout<< "Please enter Second Qrt Sales"<<div[j].name<<endl;
  4. cin>>div[j].sec;
  5. cout<< "Please enter Third Qrt Sales"<<div[j].name<<endl;
  6. cin>>div[j].thir;
  7. cout<< "Please enter Fourth Qrt Sales"<<div[j].name<<endl;
  8. cin>>div[j].four;
Reply With Quote  
Join Date: Jul 2005
Posts: 1,288
Reputation: Lerner is just really nice Lerner is just really nice Lerner is just really nice Lerner is just really nice 
Rep Power: 9
Solved Threads: 175
Lerner Lerner is offline Offline
Nearly a Posting Virtuoso

Re: quaterly sales statistics

  #10  
Oct 29th, 2007
OK, now use a nested loop to enter data into array. Here's a very basic outline of a nested loop using for loops. You have to fill in the necessary details as per your project instructions.
for() //this loop will control which row you're using
{
   for() //this loop will control which column you're using.  
   {
    }
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 6:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC