Advertisement
JOHNYTHEWINNER

WorldRecord

Jan 23rd, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6.  
  7. int main()
  8. {
  9.     double worldrecord;
  10.     double meters;
  11.     double time;
  12.  
  13.     do
  14.     {
  15.         cin.clear();
  16.         cin >> worldrecord;
  17.     }
  18.     while (cin.bad() || worldrecord < 0 || worldrecord> 100000);
  19.  
  20.     do
  21.     {
  22.         cin.clear();
  23.         cin >> meters;
  24.     }
  25.     while (cin.bad() || meters <  0 || meters> 100000);
  26.  
  27.     do
  28.     {
  29.         cin.clear();
  30.         cin >> time;
  31.     }
  32.     while (cin.bad() || time < 0 || time> 1000);
  33.  
  34.     double speed = 1 / time;
  35.     double slow = floor(meters / 15);
  36.     double newtime = (meters / speed)+ (slow*12.5);
  37.     if (newtime < worldrecord)
  38.     {
  39.         cout << "Yes, he succeeded! The new world record is " << fixed << setprecision(2) << newtime << " seconds." << endl;
  40.     }
  41.     if (newtime >= worldrecord)
  42.     {
  43.         cout << "No, he failed! He was " << fixed << setprecision(2) << (newtime-worldrecord) << " seconds slower." << endl;
  44.     }
  45.  
  46.        
  47.          
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement