Public feed
#893168
#include <iostream> // standard input/output library
#include <cstdlib> // for abs function
using namespace std;
int main()
{
//constant values for the deviations in the writeup
const int RANGEONE = 1;
const int RANGETWO = 2;
const int RANGETHREE = 3;
const int RANGEFOUR = 4;
const int RANGEFIVE = 6;
const int RANGESIX = 8;
const int RANGESEVEN = 13;
int actualtime; // actual flight time, as input by the user
int expectedtime; //expected flight time as input by user
int deviation; // deviation as outlined in writeup
// write the opening header
cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
cout << "Welcome to the Moose and Squirrel Airlines" << endl;
cout << "Flight Time Calculation Program." << endl;
cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
// user input for expected flight time
cout << "Please enter your expected flight time -> " << endl;
cin >> expectedtime;
// user input for expected flight time
cout << "Please enter your actual flight time -> " << endl;
cin >> actualtime;
// setting deviations for any given range
if (expectedtime <= RANGEONE)
{
deviation = 1;
}
else if
(expectedtime <= RANGETWO)
{
deviation = 2;
}
else if
(expectedtime <= RANGETHREE)
{
deviation = 3;
}
else if
(expectedtime <= RANGEFOUR)
{
deviation = 4;
}
else if
(expectedtime <= RANGEFIVE)
{
deviation = 6;
}
else if
(expectedtime <= RANGESIX)
{
deviation = 8;
}
else if
(expectedtime <= RANGESEVEN)
{
deviation = 13;
}
else
(expectedtime >= RANGESEVEN)
{
deviation = 17;
}
// bad data check
if (expectedtime || actualtime <= 0)
{
cout << "You have input an invalid flight time." << endl;
}
// perform calculation for acceptability
if (abs (expectedtime - actualtime) == deviation)
{
cout << "This flight time is acceptable." << endl;
}
else cout <<"This flight time is unacceptable." << endl;
cout << "Thank you for using the Moose and Squirrel Airlines" << endl;
cout << "Flight Time Calculator." << endl;
return(0);
}