View Single Post
  #7 (permalink)  
Old 07-02-2008, 11:57 PM
Aereshaa's Avatar   
Aereshaa Aereshaa is online now
Programming Professional
 
Join Date: Apr 2008
Posts: 300
Credits: 159
Rep Power: 7
Aereshaa is a jewel in the roughAereshaa is a jewel in the roughAereshaa is a jewel in the roughAereshaa is a jewel in the rough
Default Re: help with arrays...

Okay, first, it looks like you are trying to use "hours" and "charges" as types.
Code:
double hours __gc[] = new double __gc[10];
double charges __gc[] = new double __gc[10];
So, it looks like you are defining "__gc" twice, once as the (as far as I know) nonexistant type "array of double hours", and another time as "array of double charges". Later, you refer to these as "hours[]" and "charges[]". Therefore, change your bad declarations to these:
Code:
double hours[] = new double [10];
double charges[] = new double [10];
Next, if statements require () around their condition.
Code:
if hours[i] <= 2
should be
Code:
if(hours[i] <= 2)
Code:
do
Console::WriteLine( L"Enter the number of hours parked:" );
hours[i] = Double::Parse( Console::ReadLine() );
if hours[i] > 24
Console::WriteLine( L"Maximum number of hours has been exceeded");
while hours[i] > 24
Here, you tried to make a do/if statement which don't exist (at least in C).

Another error is here:
Code:
charges[i] = ((hours - 2) * .5) + 5;
You refer to "hours" which is the address of the first element of the array hours. This should be changed to "hours[0]", "hours[i]", or whatever element of the array hours[] you mean.

All in all, it looks like you're using Perl syntax in C++, so... learn C++!
Reply With Quote