comp



Last edited on
I think you can do that exercise in 1 day or less. Just use your brain for the algorithm since you have knowledge in C++.

I suggest...
1. Make your own algorithm first.
2. If you can't make your own algorithm, try to find similar exercises with source code.
3. From that source code, you can get several idea in making your own algorithm.

else...

You may list topics that u study,during you 3months.Maybe i can help you to find the way!
em we've done loops,while loops, do while loops, if statements, else if, switch. noting too more advanced than that. im on holidays for the the 4 wks and i went to do it yesterday and i just cant get my head around it.once i get some of started i should be ok. thanx
Okay,tommorrow i will do you work.Okay?
ur the best!!!im still cracking away anyway but to no avail. thanx
@Mazd
I hope you were joking...
jokin about wot???
About doing what you are expected to do
- read advice #19 http://www.cplusplus.com/forum/lounge/6195/ -
Last edited on
I'm so tight to do your work my best!But let give advice.I'm also starter but take look on this.:
you should declare number of float variable to hold score accordng to number of divers.If statement will work to test candition given above,number of testing if will depend on number of judges,for each 'if'error msg will display if the outcome is false.Then average calculation block will follow.Nothing else.Expert may correct me and give you what u need.Just am try my best to help you.
Here you go moxeyfike :)

Note how you must not use floats as your input score 0.0 -6.0 but rather as a string of chars.
I cannot explain why not right now but I will later.

I only use basic operations without using functions because maybe you havent covered it as yet in class, otherwise this code will be 5X smaller!

BTW hello everybody, i'm new to these forums, pleased to meet all fellow coders :)


/*
Name: Competition Score Programme
Copyright: -None-
Author: Insert your name
Date: 10/01/10 21:34
Description: Prompt user for number of competitors, and prompt five scores for each competitor.
The score must be between 0.0 and 6.0. Error must be displayed if this is not entered correctly.
The lowest and highest score is to be ignored and the remaining average calculated for
each competitor.
Note: Strings are actually arrays of individual characters and can be accessed just like arrays.
These characters being either numbers, symbols or letters. Also note when referring to each
element of a string, the individual characters must have a single
quotation sign on either side becuase it is a string of characters.
*/

#include <iostream>
#include <sstream>
using namespace std;

int main ()
{
do
{
string mystr1,mystr2,mystr3,mystr4,mystr5,competitionstring,ex;
int competition=0,b,c,d,e;
cout<<"How many competitors are there participating?\n\n";
getline(cin,competitionstring);
stringstream(competitionstring)>>competition;
cout<<endl<<endl<<competition<<" competitor(s).\n\n";
for (int n=1;n<=competition;n++)
{
cout<<"For competitor "<<n<<", enter the five scores awarded by all five judges.\n"
"Each score must be between, and including, 0.0-6.0.\n\n";
//------------------------------------------------------------------------------
do
{ getline (cin,mystr1);
if (mystr1[0]>='0'&&mystr1[0]<='5'&&mystr1[1]=='.'&&mystr1[2]>='0'&&mystr1[2]<='9'
||(mystr1[0]=='6'&&mystr1[1]=='.'&&mystr1[2]=='0'))
break;
else
cout <<"Incorrect value, enter again.\n";
}while (0==0);
//------------------------------------------------------------------------------
do
{ getline (cin,mystr2);
if (mystr2[0]>='0'&&mystr2[0]<='5'&&mystr2[1]=='.'&&mystr2[2]>='0'&&mystr2[2]<='9'
||(mystr2[0]=='6'&&mystr2[1]=='.'&&mystr2[2]=='0'))
break;
else
cout <<"Incorrect value, enter again.\n";
}while (0==0);
//------------------------------------------------------------------------------
do
{ getline (cin,mystr3);
if (mystr3[0]>='0'&&mystr3[0]<='5'&&mystr3[1]=='.'&&mystr3[2]>='0'&&mystr3[2]<='9'
||(mystr3[0]=='6'&&mystr3[1]=='.'&&mystr3[2]=='0'))
break;
else
cout <<"Incorrect value, enter again.\n";
}while (0==0);
//------------------------------------------------------------------------------
do
{ getline (cin,mystr4);
if (mystr4[0]>='0'&&mystr4[0]<='5'&&mystr4[1]=='.'&&mystr4[2]>='0'&&mystr4[2]<='9'
||(mystr4[0]=='6'&&mystr4[1]=='.'&&mystr4[2]=='0'))
break;
else
cout <<"Incorrect value, enter again.\n";
}while (0==0);
//------------------------------------------------------------------------------
do
{ getline (cin,mystr5);
if (mystr5[0]>='0'&&mystr5[0]<='5'&&mystr5[1]=='.'&&mystr5[2]>='0'&&mystr5[2]<='9'
||(mystr5[0]=='6'&&mystr5[1]=='.'&&mystr5[2]=='0'))
break;
else
cout <<"Incorrect value, enter again.\n";
}while (0==0);
//------------------------------------------------------------------------------

float a,b,c,d,e;
float biggest;
stringstream(mystr1)>> a;
stringstream(mystr2)>> b;
stringstream(mystr3)>> c;
stringstream(mystr4)>> d;
stringstream(mystr5)>> e;

if (a<=b && a<=c && a<=d && a<=e)
a=0;
if (b<=a && b<=c && b<=d && b<=e)
b=0;
if (c<=a && c<=b && c<=d && c<=e)
c=0;
if (d<=a && d<=b && d<=c && d<=e)
d=0;
if (e<=a && e<=b && e<=c && e<=d)
e=0;

if (a>=b && a>=c && a>=d && a>=e)
a=0;
else if (b>=a && b>=c && b>=d && b>=e)
b=0;
else if (c>=a && c>=b && c>=d && c>=e)
c=0;
else if (d>=a && d>=b && d>=c && d>=e)
d=0;
else if (e>=a && e>=b && e>=c && e>=d)
e=0;
/*Note the difference had the above 4 statements been all if's and not else if's*/
cout<<"The average score is (excluding the highest and lowest numbers):\n\n";
cout<<(a+b+c+d+e)/3<<endl<<endl<<endl<<endl<<endl<<endl;
}
cout <<"To exit, press 'e', to repeat programme continue, press any other key.\n";
getline (cin,ex);

cout <<endl;
if (ex=="e")
break;
}while(0==0);
}
1. Don't do other peoples assignments for them your only harming their progress and hurting your own income if your plan on getting a job in programming.

2. use code tags ----------------------> they are the little button on the right that look like <>
that thing is a jumbled mess, so I can only guess it is hindering the OP rather than helping.


3. welcome to the forums... bad bad way to start.
Last edited on
ive the bulk of it done already myself i was stuck on a few things1 im only doin it 3 months 2 hours a wk,its unfortunate im not blessed with some people brains!!!why are so ppl in here so up their a**, im Trying learn. thanx to everyone that helped me out cheers.
lots of swearing and return abuse... blah blah read this...

http://cplusplus.com/forum/beginner/1/

Last edited on
Topic archived. No new replies allowed.