What is wrong with my program?

Can someone tell me what is wrong with my program? I can't get it to properly run.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<iostream> 
#include<iomanip>
#include <string>
using namespace std; 

int main()
{
	string CityA, CityB;
	int PopulationA, PopulationB, Year; 
	double rateA, rateB;

	{

		cout<<"Please enter the name of the smaller city"<<endl;
		getline(cin,CityA);
		cout<<"Pleae enter the name of larger city"<<endl;
		getline(cin,CityB);

		{	
		cout<<"Please enter the population of smaller city"<<endl;
		cout<<PopulationA<<endl;

		cout<<"Please enter the population of larger city"<<endl;
		cout<<PopulationB<<endl;
		if(PopulationA <= PopulationB) 
		{
			cout<<"The smaller city should have the smallest population"<<endl;
		}
		}
		while("PopulationA>=PopulationB")

			do
			{
				cout<<"What is the annual growth rate of the smaller city"<<endl;
				cout<<CityA<<endl;
				cin >> rateA;
				cout<<"What is the annual growth rate of the larger city"<<endl;
				cout<<CityB<<endl;
				cin>>rateB;
				if(rateA<=rateB)
			{
				cout<<"The growth rate of the smaller city should be larger";
				cout<<" Than the annual growth rate of the larger city";
				cout<<endl;
			}
			}
			while(rateA<=rateB);
				cout<<"The projected populations of both cities are:";
				cout<<endl<<endl;

				cout<<"Year:";
				cout<<setw(10);
				cout<<"PopulationA:";
				cout<<setw(15);
				cout<<"PopulationB:";
				cout<<endl;
				Year++;

				{

				PopulationA=PopulationA*rateA+PopulationA;
				PopulationB=PopulationB*rateB+PopulationB;

				cout<<"Year:";
				cout<<setw(10);
				cout<<"PopulationA:";
				cout<<setw(15);
				cout<<"PopulationB:";
				cout<<endl;
				}
				cout<<"Press any key to exit"<<endl;
				cin.ignore(2);

	}
}


What do you mean by "properly run"?
I can input city names, but than after that I get error messages. I've tried to initialize the Population A and Population B, but than it just reads as an output.


Here is the problem that I need to place in a program.

This program is designed to analyze the growth of two cities. Each city has a starting population and annual growth rate. The smaller city has the larger growth rate (required). Show the comparative populations of each city year by year until the smaller city has grown larger than the bigger city.

As an example, Dogville has a population of 5000 growing at 20% annually while Cattown has a population of 7000 growing at 10% annually. The projected populations are:
Year Dogville Cattown
1 6000 7700
2 7200 8470
3 8640 9317
4 10368 10249

I'm only 3 days into learning this stuff and I'm pretty much looking at other people's code to learn or see how other people are doing it but

From what I can tell populationA/B don't have any values being assigned to them.. that's the first thing that jumps out at me without more experience or compiling

Edit
Also it says population A is the small and B is the large but the following if statement compared it the other way around. I also thought getline() left the return carrier in stream but I may be wrong
Last edited on
Topic archived. No new replies allowed.