Skip to content

Commit

Permalink
fixed bug when you're not started at 1 :/
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawrence-Link committed Aug 15, 2020
1 parent 0f3d58f commit 0be0e2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions geometric-ser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ unsigned long STOP_AT;
unsigned long PUBL_RATIO;

void calc_fail();
void multipleByC(long & _input);

int main()
{
Expand All @@ -31,13 +32,15 @@ int main()
cout << "The Public Ratio is" << endl;
cin >> PUBL_RATIO;

if (cin.good()){
if (cin.good())
{

cout << "CALCULATING STATRED." << endl;
cout << "CALCULATING STATRED." << endl;

static unsigned long proc_num = START_AT;
static long answer_final = 1;
static bool calFailedFlag = false;
static unsigned long proc_num = START_AT;
static long answer_final = START_AT;
static bool calFailedFlag = false;

do
{
proc_num *= PUBL_RATIO;
Expand All @@ -52,12 +55,15 @@ int main()

} while (proc_num != STOP_AT);

if (!calFailedFlag && cin.good()){
cout << "This is the final answer." << endl;
cout << answer_final << endl;

if (!calFailedFlag && cin.good())
{
cout << "This is the final answer." << endl;
cout << answer_final << endl;
}
}

}else {
else
{
cerr << "Input valid. Check if anything goes wrong, maybe you just entered characters?";
}
system("PAUSE");
Expand All @@ -66,5 +72,5 @@ int main()

void calc_fail()
{
cerr <<"\nCalculation failed. The answer does not exist." << endl;
cerr << "\nCalculation failed. The answer does not exist." << endl;
}
Binary file modified geometric-ser.exe
Binary file not shown.

0 comments on commit 0be0e2b

Please sign in to comment.