Thread: Help with structures

  1. #1
    Registered User
    Join Date
    Feb 2008

    Help with structures

    I am doing a problem that asks me to write a program that uses a structure named CorpData to store the following information on a company division and it asks me to store various sales numbers and division names such as east, west, south, or north.

    It then asks me to include a constructor that allows the division name and four quarterly sales amounts to be specified at the time a CorpData variable is created.

    The program should create four variables of the structure each representing one of the division. Each variable should be passed in turn to a function that calculates and stores the total sales and average quarterly sales for that division. Once this has been done for each division, each variable should be passed in turn to a function that displays the division name, total sales, and quarterly average

    I cant figure out how I can get the sales numbers in the right division. This is what I have so far. Any help would be very welcome.
    #include <iostream>
    #include <string>
    using namespace std;
    struct CorpData
    	string name
    	double firstsales,
    	{	east = "";
    		west = "";
    		north = "";
    		south = "";
    	int main()
    	CorpData east,west,north,south;
    	cout << "Enter the division name: ";
    	cin >> ;
    	return 0;

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You're missing a semicolon after string name; your main is indented rather strangely; you cin into nothing; and your direction variables such as north are declared in main yet initialized (to strings!) in the very constructor for those objects. Oops.

    If it helps, try solving the problem with one variable first, without using any structures.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Structures within Structures
    By Misko82 in forum C Programming
    Replies: 2
    Last Post: 08-27-2007, 12:25 AM
  3. Input output with structures
    By barim in forum C Programming
    Replies: 10
    Last Post: 04-27-2004, 08:00 PM
  4. pointers to arrays of structures
    By terryrmcgowan in forum C Programming
    Replies: 1
    Last Post: 06-25-2003, 09:04 AM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM