Problem with NOT using an array

I'm not allowed to use an array for this code but I can't figure out how not to.
I need the following code to work unlimited times until 999 is entered then output the information

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void process_fees(double cost)
{
	int count;
        double car[20];
	double total=0;
	cout << "Please enter the hours" << endl;
	for (int i=0; i<20; i++)//I need this to be done unlimited times
	{
	    car[i] = (process_fee() * 3.00);//I need "car" to be saved and output it later
	}
}

double process_fee()
{
	int hours;
	cin >> hours;
	if (hours == 999);
	else 
	     return hours;
}
Last edited on
closed account (S6k9GNh0)
Your post doesn't make much sense. You said you aren't allowed to use an array but I don't see an array in your current code. What's the problem?
Last edited on
To do an infinite for loop the code is: for(;;) adn then you can call your function.

Personally though, I would use a do while loop and not use a function call.
Also line 17 doesn't mean anything, there are no statements if the conidiotn is true. I think what you want is if(hours != 999) return hours; #

You don't need to use an array with numbers, using int will be fine.

EDIT*****
Not sure how i missed that before, was doing things at speed! You aren't using any arrays. The statement on line 4 is invalid. I think you need to look over your code again, or maybe restart for ease and really think about how your program is going to run, line by line.
Last edited on
What exactly are you expected to do? If you need the user to input numbers and after inputting 999 return each value * 3 in reverse order, you could use recursion.
Topic archived. No new replies allowed.