## need help with my asssignment please!!

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

### need help with my asssignment please!!

hi. i need help with my program. i have started it but im stuck and dont know what to do. im a beginner at this and not sure what im doing. i have to program statistics for 8 teams. i have to write the number of wins, losses, ties, final score and winning average. i am not not sure where i have to put the data for the first team and what do i have to do so that it repeats for the rest of the teams. thanks a lot.

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int idnumb, wins, losses, tied, totalgames, remaininggames, finalscore;
double winningaverage;

//the program will print out the statistics for eight football teams
cout<<"first football team's id number"<< endl;
cin>>idnumb;
while(idnumb>=0) {
cout<<"the number of games won are"<< endl;
cin>>wins;
cout<<"the number of games lost are"<< endl;
cin<<losses;
cout>>"the number of games tied are"<< endl;
cin<<tied;
cout<< "the number of total games played are"<< endl;
cin>>totalgames=(wins+losses+tied);
if (wins+losses+tied==16)
cout<<"the season is finished"<< endl;
else (wins+losses+tied<16)
cout<<"the season is not finished"<< endl;
cout<< "the winning average is"<< endl;
cin>>winningaverage=(wins/totalgames);
if (tied>=tied)
cout<<"number of games tied is greater than or equal to the number of games won"<< endl;
else (tied>losses)
cout<< "number of games tied is not greater than the number of games lost"<< endl;
}
cout<<'stop';
return 0;
}
iky

Posts: 2
Joined: Tue Sep 25, 2012 5:37 pm

### Re: need help with my asssignment please!!

First of all, please use [code ][/code ] tags for posting your code. Additionally it seems you miss an understanding of basic concepts you should tackle before attempting this assignment really. Some things to look into:

Code: Select all
`cin<<losses;`

You use the insertion operator (<<) on an input stream (cin, pronounced as "see-in"). You don't always seem to do this; If it's not clear now, you should look into the difference between the insertion (<<) and extraction operator.

Code: Select all
`cin>>totalgames=(wins+losses+tied);`

This doesn't make sense. The assignment of 'totalgames' does, but why do you include "cin >>" ? You should look into "streams" and "cout"/"cin" in particular.

Code: Select all
`if (wins+losses+tied==16)`

Assuming you tried to store the total amount of games previously, you could have used "totalgames" here; It's probably more clear.

Code: Select all
`else (wins+losses+tied<16)`

"else" should not be followed by a condition. It is entered on scenario's that don't statisfy earlier conditions. A typical construct could look as follows:

Code: Select all
`if (x){    Code}else if (y) // You could have multiple "else if"s.{    Code}else{    Code}`

Parenthesis are optional but it's good practice to include them, especially when you're a beginner. (without them only the first statement is considered the body of the if block)

Code: Select all
`cin>>winningaverage=(wins/totalgames);`

The same issue as earlier so not going over that one. Something to note here though is that both "wins" and "totalgames" are integers. (int) Because of this division might not behave the way you expect it to do; it always results in an integer. The decimal part is simply "cut off". For example:

Code: Select all
`1/2 = 010/11 = 01.0 / 2.0 = 0.51.0 / 2 = 0.51 / 2.0 = 0.5static_cast<double>(1)/2 = 0.5`

Look into "datatypes" and "type casting". You'll likely want to convert to a floating point type like "float"/"double" in this case. You could change the datatype although that doesn't always make sense. You could also cast it in the expression itself like I showed in the last example.

Code: Select all
`while(idnumb>=0)`

"idnumb" is not set in your loop's body, so this will never end. (assuming the code would compile in the first place) Additionally it's probably not the most logical choice, especially because you know you want to input data for exactly 8 teams. A construct I would recommend here would be a "for loop", look it up. You shouldn't have the need to enter the id number in the first place, but this depends on your assignment as well. is it desired that you can enter the data for teams in an order determined by the user?

Also, what is it you're going to do with the data? At the moment it appears you're entering a team, do a calculation, display the results and then go onto the next one. There seems to be no need to "remember" data. (Making entering 8 teams not much different than entering just 1) If this is the case you could simply re-use the variables used.

If you do have to remember data and later create some sort of ranking for example you'd probably want to look into "structs". For simplicity you could view them as "a set of data" which seems appropriate here as every team has a couple of statistics associated with them. You could also consider creating a "class" so you can make team objects that hold the data as well as member function to obtain, manipulate and perform calculations on these data. (for example, calculating the winning average. This all depends on your assignment though.

Considering what you posted I'd keep it simple and first try to understand the basics. I can help when you get a better idea of what you want and when you seem to have mastered the basic things. Try to be clear in formulating what you need help with exactly, what you want to achieve, what think your code so far does, what part you don't understand etc etc. Nobody likes a block of code with the minimalistic "need solution plz". You also won't learn from that.

Gonbe

Posts: 89
Joined: Mon May 05, 2008 1:17 pm

### Re: need help with my asssignment please!!

i want to Implement multilevel feedback queue for my university assignment, kindly send me algorithm for that
mohsin

Posts: 2
Joined: Tue Dec 04, 2012 12:50 am

### Re: need help with my asssignment please!!

how to make c++ project of sports management in more than 2 files
sunil

Posts: 1
Joined: Sat Dec 22, 2012 7:35 am

### Re: need help with my asssignment please!!

This is little bit difficult for me.But i will try.Many programming tutorials are available on the internet better you refer the tutorials.Now i am working on my assignment with the help of best essay writing services.If i got the instructions or coding about this program surely i will share for you.Do not worry you can easily complete your assignment
cathytreat

Posts: 1
Joined: Fri Dec 11, 2015 4:48 am

### Re: need help with my asssignment please!!

The c++ is a command line language, especially when we talk about data structure in C++, such as stacks etc, if you required assignment help for this task I will refer you assignment writers services, they provide best assignment writing help in Pakistan
rimi

Posts: 1
Joined: Mon Mar 07, 2016 1:26 am

### Re: need help with my asssignment please!!

It's very pretty difficult me to answer this question but C++ famous book of Robert Lafore will help you, I am recently attached with a company, They are offering the assignment writing services UK.
David Byrne

Posts: 1
Joined: Mon Mar 07, 2016 1:33 am