Thread: Error message please help

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    Smile Error message please help

    #include<iostream.h>
    void main(void)
    {
    int paint[11],
    j,
    total,
    average,
    max,min,
    less_50,
    greater_50,
    min_50=0,
    max_50=0,



    for(j=1;j<=10;j++)
    {
    cout<<"Enter the cases of paint ";
    cin>>paint[j];
    }
    max=paint[0];
    for(j=0;j<90;j++)
    {
    max=paint[1];
    for(j=1;j<=10;j++)
    {
    if(paint[j]>max)
    max=paint[j];
    }
    min=paint[1];
    for(j=1;j<=10;jtt)
    {
    if(paint[j]<min)
    min=paint[j];
    }
    max_50=0
    for(j=1;j<=10;j++)
    {
    if(paint[j]>50)
    greater_50++;
    }
    min_50=0;

    for(j=1;j<=10;j++)
    {
    if(paint[j]<50)
    less_50++;
    }

    total=0;
    for(j=1;j<=10;j++)
    {
    total=total+paint[j];
    average=total/10;
    }
    cout<<"The Average number of paint cases sold per day "<<average<<endl;
    cout<<"The Maximum number of paint cases sold per day "<<max<<endl;
    cout<<"The Minimum number of paint cases sold perday "<<min<<endl;
    cout<<"Number of days that paint sales were greater than 50 are "<<greater_50<<endl;
    cout<<"Number of days that paint sales were less than 50 are "<<less_50<<endl;
    }


    When I run this it compiles but I get negative numbers for the Number of days that paint sales were greaterthan 50 and also the next line. Now I have been told to make sure to zero things out before file name but am not sure about what they want me to do. Could some one help Please I have worked on this for awhile and am afraid I have looked to much it has to be right in front of me. C++visual basic 6.0

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    I don't see how this compiled, first off all there is a parse error in your second for statement, and there is a parse error in your declarations. You have to put a semicolon after max_50, and you should split up your int arrays and just plain ints, but I don't know if you have to or not. Also you have a parse error about midway where it says max_50=0. What compiler are you using that let this compile? Once you correct the parse errors it works nicely. Here is my revised code:

    #include<iostream.h>

    void main(void)
    {
    int paint[11];
    int j=0, total=0, average=0, max=0, min=0, less_50=0, greater_50=0, min_50=0, max_50=0;



    for(j=1;j<=10;j++)
    {
    cout<<"Enter the cases of paint ";
    cin>>paint[j];
    }
    max=paint[0];
    for(j=0;j<90;j++)
    {
    max=paint[1];
    }
    for(j=1;j<=10;j++)
    {
    if(paint[j]>max)
    max=paint[j];
    }
    min=paint[1];
    for(j=1;j<=10;j++)
    {
    if(paint[j]<min)
    min=paint[j];
    }
    max_50=0;
    for(j=1;j<=10;j++)
    {
    if(paint[j]>50)
    greater_50++;
    }
    min_50=0;

    for(j=1;j<=10;j++)
    {
    if(paint[j]<50)
    less_50++;
    }

    total=0;
    for(j=1;j<=10;j++)
    {
    total=total+paint[j];
    average=total/10;
    }
    cout<<"The Average number of paint cases sold per day "<<average<<endl;
    cout<<"The Maximum number of paint cases sold per day "<<max<<endl;
    cout<<"The Minimum number of paint cases sold perday "<<min<<endl;
    cout<<"Number of days that paint sales were greater than 50 are "<<greater_50<<endl;
    cout<<"Number of days that paint sales were less than 50 are "<<less_50<<endl;
    }

    reply if you have any more trouble.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    hello

    Thanks I did say C++Visual Basic 6.0 that what the school has Thank you for your help I appreciate it.

Popular pages Recent additions subscribe to a feed