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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <iostream>
#include <math.h>
#include <iomanip>
#include <vector>
#include <numeric>
using namespace std;
double inputVal(string min, double max);
double inputVal(double min, string max);
double inputVal(double min, double max);
int main ()
{
string minimum;
double maximum=32;
inputVal(minimum, maximum);
}
double inputVal(string min, double max)
{
double input;
cout << "Please enter a number (min: no limit, max: 32): ";
cin >> input;
while (input<=max)
{
inputVal(32.0, 212.0);
}
while (input>max)
{
cout << "Invalid input, try agian!\nPlease enter a number (min: no limit, max: 32): ";
cin >> input;
while (input<=max)
{
inputVal(32.0, 212.0);
}
}
}
double inputVal(double min, double max)
{
string maximum;
double input;
cout << "Please enter a number (min: 32, max: 212): ";
cin >> input;
while (input>=min && input<=max)
{
inputVal(212.0, maximum);
}
while (input<min || input>max)
{
cout << "Please enter a number (min: 32, max: 212): ";
cin >> input;
while (input>=min && input<=max)
{
inputVal(212.0, maximum);
}
}
}
double inputVal(double min, string max)
{
string maximum;
double input;
cout << "Please enter a number (min: 212, max: no limit): ";
cin >> input;
while (input>=min)
{
break;
}
while (input<min)
{
cout << "Invalid input, try agian!\nPlease enter a number (min: 212, max: no limit): ";
cin >> input;
}
}
|