SOURCE FILE: 030_powCalcA_1.0.cpp
/*
Here we transform the pseudo-code of the level 0.0
program into comments, and insert C++ function calls
equivalent to the pseudo-code steps. We also insert stub code
for the functions. This program can be compiled and
executed to test the correctness of the main function.
*/
#include <iostream>
using namespace std ;
/* PROTOTYPES */
void PrintInfo() ;
int GetInt() ;
bool GoodInput(int first, int second) ;
int MyPow(int base, int exponent) ;
void WriteAnswer (int base, int exp, int ans) ;
/* ************** */
/* FUNCTION: MAIN */
/* ************** */
int main (void)
{
int n, m, answer ;
/* Print info on what the program does */
PrintInfo() ;
do
{
/* get the two inputs (n and m) */
n = GetInt() ;
m = GetInt() ;
/* if n and m are both positive */
if ( GoodInput(n,m) )
{
/* compute n to the power m */
answer = MyPow (n,m) ;
/* write the answer on the screen */
WriteAnswer (n,m,answer) ;
}
} while (GoodInput(n,m)) ; /* while n and m are both positive */
return 0;
}
/* FUNCTION: PRINT INFO */
void PrintInfo()
{ /* Stub Code */
cout << "PrintInfo executes.\n" ;
}
/* FUNCTION: GET INT */
int GetInt()
{ /* Stub Code */
cout << "GetInt executes.\n" ;
return 3 ;
}
/* FUNCTION: GOOD INPUT */
bool GoodInput(int first, int second)
{ /* Stub Code */
cout << "GoodInput executes.\n" ;
cout << " Parameter first is: " << first << endl ;
cout << " Parameter second is: " << second << endl ;
/* Stub returns false to avoid infinite
loop during test of Level One program */
return false ;
}
/* FUNCTION: MY POW */
int MyPow(int base, int exponent)
{ /* Stub Code */
cout << "MyPow executes.\n" ;
cout << " Parameter base is: " << base << endl ;
cout << " Parameter exponent is: " << exponent << endl ;
return 42 ;
}
/* FUNCTION: WRITE ANSWER */
void WriteAnswer (int base, int exp, int ans)
{ /* Stub Code */
cout << "WriteAnswer executes.\n" ;
cout << " Parameter base is: " << base << endl ;
cout << " Parameter exp is: " << exp << endl ;
cout << " Parameter ans is: " << ans << endl ;
}