Hello Weechi,
I am not the best at writing pseudo-code, but the general idea is to use plain English, or whatever you language may be, to explain what needs to be done.
Going from a working program to pseudo-code is easy because you just have to explain what you did in the program.
To get you started:
define "main"
define variables. "double" is the preferred floating point type, but a "float" may work if your decimal number is small.
Define file streams.
open input file.
check if open.
if (!inputFile)
print error message.
return 1; // <--- Leave program and fix problem.
"else" block not needed.
open output file.
Check not needed unless you use a path to the file.
Give the rest a try and see what you come up with.
|
The "else" block is not needed just the code because if you leave the program in the if block the else block is not reached.
If you bypass the if block then you would continue with the program.
Just because you have an if statement does not mean that you always have to have an "else" to go with.
Another point is is usually a good idea to initialize your variables when defined.E.G., :[code]double AIR{}, MIR{}, months{}, [/ code]. The empty{}, the uniform initializer, will set the variables to "0.0". Or you could put a number inside the{}s if you need to give it a value to start with.The{}s are available from C++11 standards on.
Andy