Video Game Player Program
Write a program to do the following. In main declare a Player Name Array and a Score Array. Declare the size of the arrays to be 100. In the InputData function input the player name and score into the arrays for an unknown number of players up to 100.
2 answers
If you have a problem coding, post your code, we'll help you debug syntax or logic errors.
using namespace std;
const double poundsPerKilogram = 2.2046;
const int ouncesPerPound = 16;
const int gramsPerKilogram = 1000;
void getInput(double& pounds, double& ounces);
// Precondition: User is ready to enter values correctly.
// Postcondition: The values of pounds and ounces have been set to the weight
// of the object.
double convertToGrams(double poundss, double ounces, double kilograms, double grams);
// Precondition: User is ready to enter values correctly.
// Postcondition: The values of kilograms and grams have been set to
void giveOutput(double kilograms, double grams);
// Precondition: The weight of the object is stored in kilograms and grams.
// Postcondition: The values of kilograms and grams have been written to the screen.
int main()
{
double pounds, ounces, kilograms, grams;
char ans;
do
{
getInput(pounds, ounces);
convertToGrams(kilograms, grams, pounds, ounces);
giveOutput(kilograms, grams);
cout << "Do you want to do another calculation?\n"
<< "Press y for yes, n for no,\n"
<< "and then press return: ";
cin >> ans;
cout << endl;
} while (ans == 'y' || ans == 'Y');
return 0;
}
void getInput(double& pounds, double& ounces)
{
cout << "Enter the weight of the object in pounds and ounces\n";
cout << "pounds: ";
cin >> pounds;
cout << "ounces: ";
cin >>ounces;
}
double convertToGrams(double pounds, double ounces, double kilograms, double grams)
{
kilograms = pounds / 2.2046;
kilograms = floor(kilograms); // extract just entire portion of kg
grams = (kilograms )*1000; // the substraction will be remaining grams
return kilograms;
return grams;
}
void giveOutput(double kilograms, double grams)
{
cout << "The object weighs " << kilograms << " kilograms and " << grams << " grams\n";
}
const double poundsPerKilogram = 2.2046;
const int ouncesPerPound = 16;
const int gramsPerKilogram = 1000;
void getInput(double& pounds, double& ounces);
// Precondition: User is ready to enter values correctly.
// Postcondition: The values of pounds and ounces have been set to the weight
// of the object.
double convertToGrams(double poundss, double ounces, double kilograms, double grams);
// Precondition: User is ready to enter values correctly.
// Postcondition: The values of kilograms and grams have been set to
void giveOutput(double kilograms, double grams);
// Precondition: The weight of the object is stored in kilograms and grams.
// Postcondition: The values of kilograms and grams have been written to the screen.
int main()
{
double pounds, ounces, kilograms, grams;
char ans;
do
{
getInput(pounds, ounces);
convertToGrams(kilograms, grams, pounds, ounces);
giveOutput(kilograms, grams);
cout << "Do you want to do another calculation?\n"
<< "Press y for yes, n for no,\n"
<< "and then press return: ";
cin >> ans;
cout << endl;
} while (ans == 'y' || ans == 'Y');
return 0;
}
void getInput(double& pounds, double& ounces)
{
cout << "Enter the weight of the object in pounds and ounces\n";
cout << "pounds: ";
cin >> pounds;
cout << "ounces: ";
cin >>ounces;
}
double convertToGrams(double pounds, double ounces, double kilograms, double grams)
{
kilograms = pounds / 2.2046;
kilograms = floor(kilograms); // extract just entire portion of kg
grams = (kilograms )*1000; // the substraction will be remaining grams
return kilograms;
return grams;
}
void giveOutput(double kilograms, double grams)
{
cout << "The object weighs " << kilograms << " kilograms and " << grams << " grams\n";
}