저는 세일즈맨이 6 명 밖에없는 자동차 회사 용 프로그램을 만들고 있습니다. 이 프로그램은 사용자에게 각 영업 사원의 이름과 월급을 입력하고 한 달에 판매 한 차량 수와 각 차량의 브랜드 및 가격을 입력하도록 요청합니다. 이 프로그램은 각 영업 사원의 월 소득 (급여 + 수수료), 영업 사원의 평균 월 소득, 최고 소득을 가진 영업 사원의 이름 (수입), 영업 사원의 이름 최저 수입, 각 브랜드별로 판매 된 자동차 수 및 가장 인기있는 브랜드입니다.C++의 함수 사이에 값 전달
Salesman1() 및 Salesman2()에서 totalCommission 값을 전달하는 데 막혔습니다. 또 다른 문제는, 내가 SalesmanName이라는 배열에 문자열을 CIN 할 수 있는지 여부를 모르겠습니다. 여기까지 내가 한 일이있다. 수행
return totalCommission;
main()
에서 :
int allCommissions = 0;
을 다음 루프에서 당신은 수행합니다 SalesmanN()
기능에
int main()
{
int cycle=1;
int SalesMan1(),SalesMan2();
do
{
switch(cycle)
{
case 1: SalesMan1(); cycle++; break;
case 2: SalesMan2(); cycle++; break;
/*case 3: SalesMan3(); cycle++; break;
case 4: SalesMan4(); cycle++; break;
case 5: SalesMan5(); cycle++; break;
case 6: SalesMan6(); cycle++; break;*/
default: cout<<"Printing out reports"<<endl;
system("\npause");
}
}while(cycle<=6);
return 0;
}
int SalesMan1()
{
char NameOne[40];
int numCar=1,carSold,carType,audiSold=0,bmwSold=0,mbenzSold=0;
double salary,carPrize,commission,totalCommission,allMonthlyIncome;
cout<<"Name of 1st Salesman:"<<endl;
cin.getline(NameOne,39);
cout<<"\nMonthly Salary: RM";
cin>>salary;
cout<<"\nNumber of car sold in a month: ";
cin>>carSold;
system("CLS");
do{
cout<<"\nEnter type of car sold as below: "<<endl;
cout<<"\n1-Audi"<<endl;
cout<<"2-BMW"<<endl;
cout<<"3-Mercedes Benz"<<endl;
cout<<"\nCar Type:";
cin>>carType;
switch(carType)
{
case 1:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.02*carPrize;
totalCommission+=commission;
audiSold++;
system("CLS");
break;
case 2:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.02*carPrize;
totalCommission+=commission;
bmwSold++;
system("CLS");
break;
case 3:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.035*carPrize;
totalCommission+=commission;
mbenzSold++;
system("CLS");
break;
default :
cout<<"\nNot available!"<<endl;
system("pause");
return 1;
}
numCar++;
}while(numCar<=carSold);
allMonthlyIncome=allMonthlyIncome+totalCommission+salary;
}
int SalesMan2()
{
char NameTwo[40];
int numCar=1,carSold,carType,audiSold=0,bmwSold=0,mbenzSold=0;
double salary,carPrize,commission,totalCommission,allMonthlyIncome;
cout<<"Name of 2nd Salesman"<<endl;
cin.getline(NameTwo,39);
cout<<"\nMonthly salary: RM";
cin>>salary;
cout<<"\nNumber of car sold in a month: ";
cin>>carSold;
system("CLS");
do{
cout<<"\nEnter type of car sold as below: "<<endl;
cout<<"\n1-Audi"<<endl;
cout<<"2-BMW"<<endl;
cout<<"3-Mercedes Benz"<<endl;
cout<<"\nCar Type:";
cin>>carType;
switch(carType)
{
case 1:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.02*carPrize;
totalCommission+=commission;
audiSold++;
system("CLS");
break;
case 2:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.02*carPrize;
totalCommission+=commission;
bmwSold++;
system("CLS");
break;
case 3:
cout<<"\nEnter the price sold: RM";
cin>>carPrize;
commission=0.035*carPrize;
totalCommission+=commission;
mbenzSold++;
system("CLS");
break;
default :
cout<<"\nNot available!"<<endl;
system("pause");
return 1;
}
numCar++;
}while(numCar<=carSold);
allMonthlyIncome=allMonthlyIncome+totalCommission+salary;
}
이것이 정말로 homwork가 아니면 Java 또는 C#을 사용하지 않으시겠습니까? –
모든 경고와 디버그 정보 ('g ++ -Wall -g')로 컴파일하십시오. 그런 다음 ** 디버거 ** ('gdb')를 사용하십시오. C++ 기능을 활용하십시오! '>>'또는 [getline] (http://www.cplusplus.com/reference/string/string/getline/)을 사용하여 C++'std :: string'을 읽을 수 있습니다. [C++ 참고서] (http://www.cplusplus.com/reference/)를 읽으십시오. –
@KickButtowski, Java 또는 C#을 모른다. 나는 C++ 만 알고있다. 그리고 나는 그것에 익숙하지 않습니다. –