// Team.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
int Menu();
void setTeam();
float getAverage();
int buffer = 7;
int team[7];
int main()
{
bool exit = false;
while (exit = false)
{
int choice = Menu();
switch (choice)
{
case 1:
setTeam();
break;
case 2:
std::cout << "The average of all players is: " << getAverage() << "\n";
break;
case 3:
break;
default:
std::cout << "The value you entered was not a menu choice. Please try again.\n";
break;
}
}
return 0;
}
int Menu()
{
std::cout << "***MAIN MENU***\n";
std::cout << "(1)Set a team\n";
std::cout << "(2)Get your teams average\n";
std::cout << "\n";
int choice;
std::cin >> choice;
return choice;
}
void setTeam()
{
std::cout << "Enter each player''s average, separated by spaces, rounded to the nearest one.\n";
int i = 0;
while (buffer > i)
{
std::cin >> team[i];
i++;
}
}
float getAverage()
{
float sum;
int i = 0;
sum = team[0]+team[1]+team[2]+team[3]+team[4]+team[5]+team[6];
double ave;
ave = sum/7;
return ave;
}
Why doesn''t this work???
I used Visual C++ 6.0.
It simply quits! I think there''s something wrong with the loop, because, in debug, it runs up to the beginning of the loop and then quits. Also, i commented out the loop and it ran fine (besides the fact that it quit after all of my subfunctions)
I''ve tried everything. Anyone have any ideas?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Why doesn't this work???
This is a dumb little program i wrote just to practice using arrays, but it doesn''t work!
while (exit = false) {
...
}
Is interpreted like this:
while(1) {
exit = false;
if(!false) break;
...
}
You should use "while (exit == false) ".
...
}
Is interpreted like this:
while(1) {
exit = false;
if(!false) break;
...
}
You should use "while (exit == false) ".
thank you thank you thank you thank you thank you.
I''d learned that, but I''d just completely forgotten! Thanks a lot!
I''d learned that, but I''d just completely forgotten! Thanks a lot!
Beer Hunter,
The expression "exit = false" evaluates to "false", so it''s more like a simple...
while (false)
{
// Doesn''t matter what''s in here as it''s not executed
}
The expression "exit = false" evaluates to "false", so it''s more like a simple...
while (false)
{
// Doesn''t matter what''s in here as it''s not executed
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement