automobile program

This is a discussion on automobile program within the C++ Programming forums, part of the General Programming Boards category; with this info, My program is suppose to read this list of prices and the sales table and calculate the ...

  1. #16
    Registered User
    Join Date
    Jul 2007
    Posts
    35
    with this info, My program is suppose to read this list of prices and the sales table and calculate the total dollar sales for each salesperson and the total dollar sales for all salespersons
    The prices for ten automobiles are as follows:
    0 $17,450
    1 $19,995
    2 $26,500
    3 $25,999
    4 $10,400
    5 $18,885
    6 $11,700
    7 $14,440
    8 $17,900
    9 $19,550

    Given sales table:
    Salesperson
    Model: 1 2 3 4 5 6 7 8: Totals

    1 0 0 2 0 5 6 3 0: 16
    2 5 1 9 0 0 2 3 2: 22
    3 0 0 0 1 0 0 0 0: 1
    4 1 1 1 0 2 2 2 1: 10
    5 5 3 2 0 0 2 5 5: 22
    6 2 2 1 0 1 1 0 0: 7
    7 3 2 5 0 1 2 0 4: 17
    8 3 0 7 1 3 5 2 4: 25
    9 0 2 6 1 0 5 2 1: 17
    10 4 0 2 0 3 2 1 0: 12

    Totals: 23 11 35 3 15 27 16 17

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    loops only loop the code that is in the body, meaning the part in the braces, the { and }.
    Code:
    for(j=0;j<=8;j++)
    {
    	for(i=0;i<=10;i++)
    	{
    		iTotSalesperPerson[j]+=iSales[j][i]; //repeats 9 * 11 times
    	}
    }
    cout << iTotSalesperPerson[j]; //only is run once.
                                   //equivalent to cout << iTotSalesperPerson[9]; which is an uninitialized variable.
    refer to vart's post above.

    http://www.cprogramming.com/tutorial/lesson3.html
    http://www.cprogramming.com/tutorial.html

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21