Hello all.  I am currently working with structures in my class and 
need a little boast.  This is what I have:

I am writing a program out of the Gaddis book and have developed a 
structure and constructor.  I know how to create the structure and 
constructor with set parameters and then declare variables in main 
and display to screen, but I'm not sure how to take input from the 
user for these parameters.  Instead of the set default parameters I 
would like to have the user enter amount for sales in each quarter.  
Perhaps I am just missing something small here.  Any boast would be 
appreciated. 

Write a program that uses a structure named CorpData to store the 
following informatoin on a 
company division:
        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.

Include a constructor that allows the division anme and four 
quarterly sales amounts to be specified 
at the time a CorpData variable is created.

The program should create four variables of this structure, each 
representing one of the following 
corpparate divisions: East, West, North, and South.  Each variable 
should be passed in turn to a 
function that calculates and stores the total sales and average 
quarterly passed in turn to a fuction 
that displays the division name, total sales, and quarterly average.
**********************************************************************
*******************************/


#include <iostream>
#include <string>
using namespace std;

struct CorpData
{
        string divisionName;       // Div name -- declare a string
        double firstQuarterSales,  // Declaring double variables
                   secondQuarterSales,
                   thirdQuarterSales,
                   fourthQuarterSales,
                   totalAnnualSales, 
                   averageQuarterlySales;

        // Constuctor with 5 parameters.  I added default values

        CorpData(string n = "division", double first = 111, double    
second = 222, double third = 333, double fourth = 444)
        {
                divisionName = n;
                firstQuarterSales = first;
                secondQuarterSales = second;
                thirdQuarterSales = third;
                fourthQuarterSales = fourth;
        }
};

int main()
{
        //      Create four CorpData variables for each division: 
East, West, North, and South.
        // THIS IS MY TROUBLE AREA..............................
        
        CorpData divisionEast;
        //CorpData divisionWest;
        //CorpData divisionNorth;
        //CorpData divisionSouth;


        cout << divisionEast.divisionName << 
divisionEast.firstQuarterSales;

        return(0);
}


Reply via email to