fork download
  1. // Personal Best
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main() {
  8. string name;
  9. string dateFirst, dateSecond, dateThird;
  10. double firstVault, secondVault, thirdVault;
  11.  
  12. // Get user input for name and date.
  13. cout << "Enter the athlete name\n";
  14. cin >> name;
  15.  
  16. cout << "Enter the first date of the ahtlete's vault\n";
  17. cin >> dateFirst;
  18. cout << "Enter the athlete's best vaults height on this date\n";
  19. cin >> firstVault;
  20.  
  21.  
  22. // Validate user input
  23. if (firstVault >= 2 && firstVault <=5 )
  24. {
  25. cout << "Enter the second date of the ahtlete's vault\n";
  26. cin >> dateSecond ;
  27. cout << "Enter the athlete's best vaults heights on this date\n";
  28. cin >> secondVault;
  29.  
  30. if (secondVault >= 2 && secondVault <=5)
  31. {
  32. cout << "Enter the third date\n";
  33. cin >> dateThird ;
  34. cout << "Enter the athlete's best vaults on this date\n";
  35. cin >> thirdVault;
  36.  
  37. if (thirdVault <= 2 && thirdVault >=5)
  38. {
  39. cout << "Only enter values from 2-5 metres\n";
  40. }
  41. }
  42.  
  43. else
  44. {
  45. cout << "Only enter height vaultes in the range of\n";
  46. cout << "2 metres to 5 metres\n";
  47. }
  48. }
  49.  
  50. else
  51. cout << "Only enter height vaultes in the range of 2 metres to 5 metres\n";
  52.  
  53. // Display the output
  54. cout << "List of best vaults made by " << name << endl;
  55. cout << "__________________________________________\n";
  56.  
  57. // Making decisions of the list of best vaults
  58. if ((firstVault > secondVault) && ( firstVault > thirdVault))
  59. {
  60. cout << "The best vault made was " << firstVault << endl;
  61. cout << "And it was made on " << dateFirst << endl;
  62.  
  63. if (secondVault > thirdVault)
  64. {
  65. cout << "The second best vault made was " << secondVault << endl;
  66. cout << "And it was made on " << dateSecond << endl;
  67. cout << "The third best vault made was " << thirdVault << endl;
  68. cout << "And it was made on " << dateThird << endl;
  69. }
  70.  
  71. else
  72. {
  73. cout << "The second best vault made was " << thirdVault << endl;
  74. cout << "And it was made on " << dateThird << endl;
  75. cout << "The third best vault made was " << secondVault << endl;
  76. cout << "And it was made on " << dateSecond << endl;
  77. }
  78. }
  79.  
  80. else if ((secondVault > firstVault) && (secondVault > thirdVault))
  81. {
  82. cout << "The best vault made was " << secondVault << endl;
  83. cout << "And it was made on " << dateSecond << endl;
  84.  
  85. if (firstVault > thirdVault)
  86. {
  87. cout << "The second best vault made was " << firstVault << endl;
  88. cout << "And it was made on " << dateFirst << endl;
  89. cout << "The third best vault made was " << thirdVault << endl;
  90. cout << "And it was made on " << dateThird << endl;
  91. }
  92.  
  93. else
  94. {
  95. cout << "The second best vault made was " << thirdVault << endl;
  96. cout << "And it was made on " << dateThird << endl;
  97. cout << "The third best vault made was " << firstVault << endl;
  98. cout << "And it was made on " << dateFirst << endl;
  99. }
  100. }
  101. else
  102. {
  103. cout << "The best vault made was " << thirdVault << endl;
  104. cout << "And it was made on " << dateThird << endl;
  105.  
  106. if (firstVault > secondVault)
  107. {
  108. cout << "The second best vault made was " << firstVault << endl;
  109. cout << "And it was made on " << dateFirst << endl;
  110. cout << "The third best vault made was " << secondVault << endl;
  111. cout << "And it was made on " << dateSecond << endl;
  112. }
  113.  
  114. else
  115. {
  116. cout << "The second best vault made was " << secondVault << endl;
  117. cout << "And it was made on " << dateSecond << endl;
  118. cout << "The third best vault made was " << firstVault << endl;
  119. cout << "And it was made on " << dateFirst << endl;
  120. }
  121. }
  122.  
  123.  
  124. return 0;
  125. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Enter the athlete name
Enter the first date of the ahtlete's vault
Enter the athlete's best vaults height on this date
Only enter height vaultes in the range of 2 metres to 5 metres
List of best vaults made by 
__________________________________________
The best vault made was 1.15304e-310
And it was made on 
The second best vault made was 1.15304e-310
And it was made on 
The third best vault made was 1.15304e-310
And it was made on