mercredi 16 septembre 2020

What is Fpermissive? How can i use it to solve errors?

Morning all, Im writing a small program in c++ where the user inputs certain yes/ no answers using while loops and if statements etc.

I have encountered a problem that i dont know how to resolve, but the error messagse tells me that i can solve this using fpermissive.

#include <stdio.h>
#include <iomanip>
#include <iostream>


using namespace std;
int main()
{
    std::cout<<std::setprecision(2)<<std::fixed;
    const double other_fee=12000;
    const double bsc_fee=15000;

    int distance[3]={0};
    double incomes[3]={0};
    double kms_price[]={65.00,100.00,150.00};
    int maxIndex=0;
    int participant_number=0, club_number=0,dist;
    double total_amt=0;
    string max_income_category;
    char regis_awnser,club_awnser;

    cout<< "Do you want to register as a participant( Y or N ): ";
    cin>> regis_awnser;
    if(regis_awnser=='N' || regis_awnser=='n')
    {
        maxIndex=-1;
    }
    while (regis_awnser=='Y'||regis_awnser=='y')
    {
        participant_number++;
        cout<< "Member of club (Y or N): ";
        cin>>club_awnser;
        if(club_awnser=='Y'||club_awnser=='y')
        {
            club_number++;
        }
    cout<<" Enter distance(5/ 10 / 15): ";
    cin>> dist;
    if(dist==5)
    {
        distance[0]++;
        if(club_awnser=='Y'||club_awnser=='y')
        {
            incomes[0]+=65*1.25;
        }
        else{
            incomes[0]+=65;
        }
    }
else if(dist==10)
{
    distance[1]++;
    if(club_awnser=='Y'||club_awnser=='y')
    {
        incomes[1]+=100;
    }
}
else{
    distance[2]++;
    if(club_awnser=='Y'||club_awnser=='y')
    {
        incomes[2]+=150*1.5;
    }
    else{
        incomes[2]+=150;
    }
}
cout<<" Do you want to register a participant( Y or N ): ";
cin>>regis_awnser;
    }
cout<<"\n Total number of participants: "<<participant_number<<endl;
cout<<" Total number of club member registrated: "<<club_number<<endl;
cout<<endl;
cout<<"Number of participants per category" <<endl;

for(int i=1;i<=3;i++);
    {
    cout<< setw(2)<<right<<(i*5)<<setw(20)<<left<<"Kilometers:"<<setw(10)<<left<< distance[i-1]<<left<<distance[i-1]<<;
    if(incomes[maxIndex]<incomes[i-1]){
        maxIndex=i-1;
    }
    total_amt+=incomes[i-1];
}
if(maxIndex==0){
    max_income_category="5Km";
}
else if(maxIndex==1){
    max_income_category="10Km";
}
else if(maxIndex==3){
    max_income_category="15Km";
}
else{
    max_income_category="--";
}
cout<<"\n Total income"<<setw(20)<<right<<"R"<<total_amt<<endl;
cout<<"Category with highest income: "<<max_income_category<<endl:
    return 0;
}

The error is in line 79:

cout<< setw(2)<<right<<(i*5)<<setw(20)<<left<<"Kilometers:"<<setw(10)<<left<< distance[i-1]<<left<<distance[i-1]<<;


error: name lookup of 'i' changed for ISO 'for' scoping [-fpermissive]| #the error
note: (if you use '-fpermissive' G++ will accept your code)|

Any help would be greatly appreciated.

The program takes a series of 2 yes or no answers and the chosen distance the user inputs, and then determinants the price for the amount of entries

Aucun commentaire:

Enregistrer un commentaire