Hey all. Worlds worst programmer here. I have some issues regarding this latest torture.........oops I meant assignment. I'm basically researching data online about world population growth for the next seventy years and output the info. Now, considering that ideally, I would like to skip having to print out the full 75 years worth of data onto the program, I decided to create a while loops.
The only problem I ran into, is that for some reason, it wasn't incrementing the rather large number of yearly population increase. For the sake of making this program as simple as possible, is it possible to create a sort of exponential increment? The code is below. Any pointers would be great.
// Lab 2c, Tabular Formatting
// Programmer: Jesse Burns
// Editor(s) used: JNotePad
// Compiler(s) used: VC++ 2010 Express
// The necessary C++ file library
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;
#include <string>
using std::string;
using std::getline;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::left;
using std::right;
#include <cstdlib>
int main()
{
// Jesse Burns, Lab 2c.
cout << "Lab 2c, Tabular Formatting\n";
cout << "Programmer: Jesse Burns\n";
cout << "Editor(s) used: JNotePad\n";
cout << "Compiler(s) used: VC++ 2010 Express\n";
cout << "File: " << __FILE__ << endl;
cout << "Compiled: " << __DATE__ << " at " << __TIME__ << endl << endl;
//The variables needed to show initial year population and subsequent growth
longlong totalpop = 7209120128;
longlong growthyear = 100927654;
longlong growthplus;
int loop = 1;
int year = 2013;
//The cout for header
cout << "World Population Growth estimate for next 75 years." << endl;
cout << "------------------------------------------------------" << endl;
//A while loop to increment the year and population up to seventy five years.
while (loop <= 75)
{
//The math needed for conversion
loop++;
growthplus = totalpop + growthyear;
year++;
//The cout necessary to show that year to year growth.
cout << year << setw(21) << growthplus <<endl;
}
}