licker
asked on
C++ program
I have some code that is meant to prompt the user to enter 10 scores and choose one of three structures(if, while, or do-while) to then evaluate and display the name, score(%), and letter grade. This is to be done using call by value. I have spent hours on this and keep getting an external linker error. What am I doing wrong? Do I need all of these libraries?
#include <iostream.h>
#include <conio.h>
#include<ctype.h>
#include<iomanip.h>
#include<stdlib.h>
#include<math.h>
int Prompt_User_For_Selection( char);
int Service_Selection_Using_If Else(char) ;
int Determine_LtrGrd_Using_Swi tch(float) ;
int main()
{
char x;
clrscr(); //clear screen
Prompt_User_For_Selection( x);
}
int Prompt_User_For_Selection( char start)
{
char ans,y;
do{
clrscr();
cout<<"STRUCTURE SELECTION\n";
cout<<"\n";
cout<<"While W\n";
cout<<"DO While D\n";
cout<<"For F\n";
cout<<"\n";
cout<<"Enter Selection <Q to Quit>:\n";
cout<<"\n\n\t";
getch();
cin>>ans;
ans=toupper(ans);
}while(ans!='W'&& ans!='D'&& ans!='F'&& ans!='Q');
if (ans!='Q')
return 0;
else
clrscr();
cout<<"\n\n\tYou Selected to Quit BYE";
cout<<"\n\n\tHit any key to exit:";
getch();
ans=start;
y=Service_Selection_Using_ IfElse(ans );
return(y);
}
int Service_Selection_Using_If Else(char ans2)
{
char choice;
int final;
int Execute_While_Loop();
int Execute_Do_While_Loop();
int Execute_For_Loop();
char firstname[20];
cout<<"Enter Your First Name:\n";
cin>>firstname;
char lastname[20];
cout<<"Enter Your Last Name:\n";
cin>>lastname;
clrscr();
if(choice=='W'){
cout<<"\n\n\tYou Selected the While Structure\n";
choice=ans2;
Execute_While_Loop();
}
else
if(choice=='D'){
cout<<"\n\n\tYou Selected the Do While Structure\n";
choice=ans2;
Execute_Do_While_Loop();
}
else
if(choice=='F'){
cout<<"\n\n\tYou Selected the For Structure\n";
choice=ans2;
Execute_For_Loop();
}
cout<<"\n\n\n\n\tStudent Name:\t"<<firstname<<' '<<lastname<<endl<<endl;
cout<<"\tGrade Average:\t"<<final<<"%"<<e ndl;
final=Determine_LtrGrd_Usi ng_Switch( choice);
return(final);
cout<<"\n\n\tHit any key to continue:";
getch();
}
int Execute_While_Loop(float avg)
{
int zz,result;
int total,
scoreCounter,
score;
total=0;
scoreCounter=1;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
total=total+score;
while(scoreCounter<10){
while(score>100||score<0){
cout <<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
total=total+score;
++scoreCounter;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
clrscr();
zz=static_cast<float>(tota l)/scoreCo unter;
zz=avg;
result=Determine_LtrGrd_Us ing_Switch (zz);
return (result);
}
int Execute_Do_While_Loop(floa t avg2)
{
int qq,result2;
int total,
scoreCounter,
score;
total=0;
scoreCounter=1;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
total=total+score;
do{
cout <<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
do{
total=total+score;
++scoreCounter;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}while(scoreCounter<10&&sc ore>=0&&sc ore<=100);
}while(score>100||score<0) ;
clrscr();
qq=static_cast<float>(tota l)/scoreCo unter;
qq=avg2;
result2=Determine_LtrGrd_U sing_Switc h(qq);
return result2;
}
int Execute_For_Loop(float avg3)
{
int vv,result3;
int total,
score,
scoreCounter;
for(int total=0,scoreCounter=1;sco reCounter< =10;++scor eCounter,
total=total+score){
for(int scoreCounter;0>score||scor e>100;scor eCounter){
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
clrscr();
vv=static_cast<float>(tota l)/scoreCo unter;
vv=avg3;
result3=Determine_LtrGrd_U sing_Switc h(vv);
return(vv);
}
int Determine_LtrGrd_Using_Swi tch(float results)
{ int last;
char LtrGrd;
LtrGrd=floor(last*10+.5)/1 00;
switch(LtrGrd){
case 10:
case 9:
cout<<"\n\tLetter Grade:\t"<<"A";
break;
case 8:
cout<<"\n\tLetter Grade:\t"<<"B";
break;
case 7:
cout<<"\n\tLetter Grade:\t"<<"C";
break;
case 6:
cout<<"\n\tLetter Grade:\t"<<"D";
break;
case 5:
cout<<"\n\tLetter Grade:\t"<<"F";
break;
}
last=results;
return 0;
}
#include <iostream.h>
#include <conio.h>
#include<ctype.h>
#include<iomanip.h>
#include<stdlib.h>
#include<math.h>
int Prompt_User_For_Selection(
int Service_Selection_Using_If
int Determine_LtrGrd_Using_Swi
int main()
{
char x;
clrscr(); //clear screen
Prompt_User_For_Selection(
}
int Prompt_User_For_Selection(
{
char ans,y;
do{
clrscr();
cout<<"STRUCTURE SELECTION\n";
cout<<"\n";
cout<<"While W\n";
cout<<"DO While D\n";
cout<<"For F\n";
cout<<"\n";
cout<<"Enter Selection <Q to Quit>:\n";
cout<<"\n\n\t";
getch();
cin>>ans;
ans=toupper(ans);
}while(ans!='W'&& ans!='D'&& ans!='F'&& ans!='Q');
if (ans!='Q')
return 0;
else
clrscr();
cout<<"\n\n\tYou Selected to Quit BYE";
cout<<"\n\n\tHit any key to exit:";
getch();
ans=start;
y=Service_Selection_Using_
return(y);
}
int Service_Selection_Using_If
{
char choice;
int final;
int Execute_While_Loop();
int Execute_Do_While_Loop();
int Execute_For_Loop();
char firstname[20];
cout<<"Enter Your First Name:\n";
cin>>firstname;
char lastname[20];
cout<<"Enter Your Last Name:\n";
cin>>lastname;
clrscr();
if(choice=='W'){
cout<<"\n\n\tYou Selected the While Structure\n";
choice=ans2;
Execute_While_Loop();
}
else
if(choice=='D'){
cout<<"\n\n\tYou Selected the Do While Structure\n";
choice=ans2;
Execute_Do_While_Loop();
}
else
if(choice=='F'){
cout<<"\n\n\tYou Selected the For Structure\n";
choice=ans2;
Execute_For_Loop();
}
cout<<"\n\n\n\n\tStudent Name:\t"<<firstname<<' '<<lastname<<endl<<endl;
cout<<"\tGrade Average:\t"<<final<<"%"<<e
final=Determine_LtrGrd_Usi
return(final);
cout<<"\n\n\tHit any key to continue:";
getch();
}
int Execute_While_Loop(float avg)
{
int zz,result;
int total,
scoreCounter,
score;
total=0;
scoreCounter=1;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
total=total+score;
while(scoreCounter<10){
while(score>100||score<0){
cout <<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
total=total+score;
++scoreCounter;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
clrscr();
zz=static_cast<float>(tota
zz=avg;
result=Determine_LtrGrd_Us
return (result);
}
int Execute_Do_While_Loop(floa
{
int qq,result2;
int total,
scoreCounter,
score;
total=0;
scoreCounter=1;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
total=total+score;
do{
cout <<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
do{
total=total+score;
++scoreCounter;
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}while(scoreCounter<10&&sc
}while(score>100||score<0)
clrscr();
qq=static_cast<float>(tota
qq=avg2;
result2=Determine_LtrGrd_U
return result2;
}
int Execute_For_Loop(float avg3)
{
int vv,result3;
int total,
score,
scoreCounter;
for(int total=0,scoreCounter=1;sco
total=total+score){
for(int scoreCounter;0>score||scor
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
cout<<"\n\n\tEnter Score number"<<' '<<scoreCounter<<":\t";
cin>>score;
}
clrscr();
vv=static_cast<float>(tota
vv=avg3;
result3=Determine_LtrGrd_U
return(vv);
}
int Determine_LtrGrd_Using_Swi
{ int last;
char LtrGrd;
LtrGrd=floor(last*10+.5)/1
switch(LtrGrd){
case 10:
case 9:
cout<<"\n\tLetter Grade:\t"<<"A";
break;
case 8:
cout<<"\n\tLetter Grade:\t"<<"B";
break;
case 7:
cout<<"\n\tLetter Grade:\t"<<"C";
break;
case 6:
cout<<"\n\tLetter Grade:\t"<<"D";
break;
case 5:
cout<<"\n\tLetter Grade:\t"<<"F";
break;
}
last=results;
return 0;
}
ASKER
It says:
[Linker Error] Unresolved external 'Execute_While_Loop()' referenced from C:\WINDOWS...
[Linker Error] Unresolved external 'Execute_Do_While_Loop()' referenced from C:\WINDOWS...
[Linker Error] Unresolved external 'Execute_For_Loop()' referenced from C:\WINDOWS...
[Linker Error] Unresolved external 'Execute_While_Loop()' referenced from C:\WINDOWS...
[Linker Error] Unresolved external 'Execute_Do_While_Loop()' referenced from C:\WINDOWS...
[Linker Error] Unresolved external 'Execute_For_Loop()' referenced from C:\WINDOWS...
Have you tried putting the function prototypes for the 3 functions at the top of the program ??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx, I played with it and got it to work, though a little differently.
Perhaps if you give us some details on the linker error we could help?