I had this working before, but I modified it and it stop working. So, I change the code back to when it was working and I'm not getting the same results.

Here is what I'm getting.

How many employees you want to enter?
3

Enter gross pay for each employee:
200
300
400

Here is the gross pay calculated for each employee:
0218
1227
2236

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
	double weeklyPay[5];
	//double payOut[5];
	int count = 0;
	double money = 0;

	cout << "How many employees you want to enter?\n";
	cin >> count;

	cout << "Enter gross pay for each employee: \n";
	
	for(int i = 0; i < count; i++)
	{
		cin >> weeklyPay[i];
	}

	cout << " Here is the gross pay calcuated for each employee: \n";

	for(int i = 0; i < count; i++)
	{
		money = (weeklyPay[i] * .09) + 200;

		cout << i <<  money << endl;
	}
	
	return 0;
}

So what is your error? Or what is going wrong?

It's not storing the calculated value.

No, look at the other calculations.

0218
1227 - should be 327
2236 - should be 436

if you look closesly, its running through the loop and printing out the i value, which you asked it to do, on the same line as the money value.

//you have
cout << i <</n money << endl;
/*try taking out the i, it is just printing 2 numbers each time it runs. e.g. 0 2, 1 2, 2 2. This is where you get the : 0218, 1227, 2236*/
//So your code should be
cout << "Employee: "<< i << " Money: "<< money << endl;
// or something similar

Edited 6 Years Ago by Akill10: n/a

Comments

No, look at the other calculations.

0218
1227 - should be 327
2236 - should be 436

if you look closesly, its running through the loop and printing out the i value, which you asked it to do, on the same line as the money value.

//you have
cout << i <</n money << endl;
/*try taking out the i, it is just printing 2 numbers each time it runs. e.g. 0 2, 1 2, 2 2. This is where you get the : 0218, 1227, 2236*/
//So your code should be
cout << "Employee: "<< i << " Money: "<< money << endl;
// or something similar

Thanks for taking the time and effort to help me out! My eyes must of been tired due to looking at the screen too long.

This question has already been answered. Start a new discussion instead.