I have this school project I've been working on most of the day.
It'll be easier if you read the whole thing first.
-----------------------------------------------------------------------------
In notepad, write a program that will ask the user for the time it took him/her to finish the race. Input validation: Accept only positive numbers for the times.
The program compares the user’s time to that of two other runners, and the time it took each runner (including the user) to finish the race. The times of the two other runners will be in the program code. No user input will be needed.
Each runner should have a unique name (related to your theme) to identify the place of that runner in the marathon.
The program will calculate who placed first, second and third in the race.
Then ask the user if he/she would like to display a congratulatory certificate. If the user answers yes show the user the certificate. If the user answers no, thank the user for participating and show the user a flyer with information for next year’s marathon. Use appropriate formatting to make it look like an actual certificate (borders, centered, etc.)
----------------------------------------------------------------------------
If you're still reading, I appreciate it and you're awesome :)
I've been going around several methods only to realize that it's not gonna work halfway through or that I can't employ it efficiently. I'll show you my current work below.
Please keep in mind I'm still a beginner in C++ so I apologize if there's something stupid in there.
I'll keep trying to find the right way to do it in the meantime.
Thanks!
====================================================================
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int User_Time;
unsigned seed = time(0);
srand(seed);
cout << "Hello, Whipcream, What was your completion time?" << endl;
cin >> User_Time;
cout << "Your time was " << User_Time << endl;
//I want to make rand() be a number with 4 significant digits, with 2 decimal places...
cout << setprecision(4) << fixed << showpoint << endl;
cout << "Syrup's time was " << rand() << endl;
cout << "Cookie's time was " << rand() << endl;
return 0;
}
|