Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ThursdayTG committed Feb 8, 2022
1 parent d289d42 commit c06136f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 9 additions & 4 deletions prime_numbers-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ int main()

do
{
cout << "\n";
cls();
cout << "\n";

//=== user input ===
int lowerBound = 0;
Expand All @@ -45,18 +46,22 @@ int main()
int inputStage = 0; // used to control std::couts of inputFunction()

inputStage++;
lowerBound = inputFunction(inputStage, 0);
lowerBound = inputFunction(inputStage, 0);

inputStage++;
upperBound = inputFunction(inputStage, lowerBound);
upperBound = inputFunction(inputStage, lowerBound+1);

inputStage++;
amountColumns = inputFunction(inputStage, 1);
}


//=== output of corrected user input ===
cls();

cout << "\n "
<< "lower bound: " << lowerBound << "\n "
<< "upper bound: " << upperBound << "\n "
<< "amount columns: " << amountColumns << "\n ";


//=== output - header ===
Expand Down
12 changes: 7 additions & 5 deletions prime_numbers-user_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using std::string;
using std::stoi;


//==============================================================================
//=== core function ============================================================


int inputFunction(int inputStage, int comparable)
Expand Down Expand Up @@ -51,14 +51,16 @@ int inputFunction(int inputStage, int comparable)
if (input == "help")
{
return 0;
}
} // WIP

if (stoi(input) <= comparable)
if (stoi(input) < comparable)
{
cout << " error: input value MUST NOT be lower than " << comparable << "!";
cout << " "
<< "===== ERROR: input value MUST NOT be lower than " << comparable << "! ====="
<< "\n\n";
}
}
while (stoi(input) <= comparable);
while (stoi(input) < comparable);

return stoi(input);
}
Expand Down

0 comments on commit c06136f

Please sign in to comment.