/* Samir M. Nassar
* samir.nassar@steamedpenguin.com
* License: GNU Public License version 3
* Title: To Give Ones Best
*/
#include
#include
#include
using namespace std;
int main()
{
char vaulterName[63];
cout << "Enter your name:" << endl;
cin.getline( vaulterName, 63);
cout << endl;
cout << "Enter three dates and their pole vault heights" << endl;
cout << endl;
// Entering data for first date
float vaultHeight1;
char vaultDate1[27];
cout << endl;
cout << "Enter the date for the first vault: " << endl;
cin.getline( vaultDate1, 27);
cout << endl;
cout << "Now enter the vault height for that date: " << endl;
cin >> vaultHeight1;
cin.ignore();
if ( vaultHeight1 < 2.0 || vaultHeight1 > 5.0 )
{
cout << endl;
cout << "You entered a an invalid value!" << endl;
cout << "Enter a value that is no smaller than 2.0 feet and no";
cout << " larger than 5.0 feet!" << endl;
cout << endl;
cout << "This program will now quit." << endl;
return 1;
}
//Entering data for second date
float vaultHeight2;
char vaultDate2[27];
cout << endl;
cout << "Enter the date for the second vault: " << endl;
cin.getline( vaultDate2, 27);
cout << endl;
cout << "Now enter the vault height for that date: " << endl;
cin >> vaultHeight2;
cin.ignore();
if ( vaultHeight2 < 2.0 || vaultHeight2 > 5.0 )
{
cout << endl;
cout << "You entered a an invalid value!" << endl;
cout << "Enter a value that is no smaller than 2.0 feet and no larger";
cout << " than 5.0 feet!" << endl;
cout << endl;
cout << "This program will now quit." << endl;
return 1;
}
//Entering data for third date
float vaultHeight3;
char vaultDate3[27];
cout << endl;
cout << "Enter the date for the third vault: " << endl;
cin.getline( vaultDate3, 27);
cout << endl;
cout << "Now enter the vault height for that date: " << endl;
cin >> vaultHeight3;
cin.ignore();
if ( vaultHeight3 < 2.0 || vaultHeight3 > 5.0 )
{
cout << endl;
cout << "You entered a an invalid value!" << endl;
cout << "Enter a value that is no smaller than 2.0 feet and no";
cout << " larger than 5.0 feet!" << endl;
cout << endl;
cout << "This program will now quit." << endl;
return 1;
}
//Now let's evaluate which height is the best
cout << endl;
cout << "The best vaults by " << vaulterName << " were:" << endl;
if ( vaultHeight1 >= vaultHeight2 && vaultHeight1 >= vaultHeight3 )
{
if ( vaultHeight2 >= vaultHeight3 )
{
// 1 > 2 > 3
cout << left << setw(10) << "First: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
}
else
{
// 1 > 3 > 2
cout << left << setw(10) << "First: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
}
}
else if ( vaultHeight2 >= vaultHeight1 && vaultHeight2 >= vaultHeight3 )
{
if ( vaultHeight1 >= vaultHeight3 )
{
// 2 > 1 > 3
cout << left << setw(10) << "First: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
}
else
{
// 2 > 3 > 1
cout << left << setw(10) << "First: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
}
}
else
{
if ( vaultHeight1 >= vaultHeight2 )
{
// 3 > 1 > 2
cout << left << setw(10) << "First: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
}
else
{
// 3 > 2 > 1
cout << left << setw(10) << "First: " << vaultHeight3 << endl;
cout << " " << "On " << vaultDate3;
cout << endl;
cout << left << setw(10) << "Second: " << vaultHeight2 << endl;
cout << " " << "On " << vaultDate2;
cout << endl;
cout << left << setw(10) << "Third: " << vaultHeight1 << endl;
cout << " " << "On " << vaultDate1;
cout << endl;
}
}
return 0;
}