How do i make this loop and look like this? The program is supposed to retrieve values for 'score and 'weight' from a funtion,
getdata.. The function returns a
bool data type. If the value returned is
true values for score and weight are updated and there are more values to retrieve. If the function returns a
false, the 'final exam' score and weight are returned and the function should not be called again.
Note: Each time the program runs the data retrieved will be different as will the answers.
i dont know how to loop the score and weight values... thanks for helping.
http://img511.imageshack.us/img511/5...mageip8.th.jpg
[php]#include <vcl.h>
#pragma hdrstop
#include<iomanip>
#include<iostream>
#include<stdlib>
//#include<conio> //Leave this comment line in
using namespace std;
bool getdata(int &,int &);
int main(int argc, char* argv[])
{
int score, weight;
double sumProduct, // The sum of the products of the weight and the score;
sumWeight, // The sum of the weights
average; // the Semester average= sumProduct/sumWeight
char grade; //letter grade based on the above average
randomize();
bool next=getdata(score,weight);
// getch(); //leave this comment line in
while (next != false)
{
cout << score << " " << weight << endl;
cin.ignore();
//}
//else
//{
}
return 0;
cout << "the number of scores: " << score << endl;
}
// beginning of getdata function
//Do not modify this function
bool getdata(int &score,int &weight)
{
static int final =rand()%30+20;
score=rand()%100+1;
weight=rand()%100+1;
final--;
if(final >0)
{
if (weight < 25)
weight=10;
else
weight=5;
return true;
}
else
{
weight=25;
return false;
//cout << "Sum of the Product: " <<
}
}
//---------------------------------------------------------------------------[/php]