473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help with arrays

errors displayed when i tried o compile my program:.\project5.cpp(9) :
error C4980: '__gc' : use of this keyword requires /clr:oldSyntax
command line option
.\project5.cpp(15) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(20) : error C2061: syntax error : identifier 'hours'

this is my program:
// project5.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^^args)
{
int hours __gc[ 10 ];
int charges __gc[ 10 ];

Console::WriteLine( L"Enter the number of hours parked:" );
hours[10] = Int32::Parse( Console::ReadLine() );

if hours <= 2
charges = 5
else
charges = (hours – 2) * .50 + 5.00;

if hours 10
charges = 10;

Console::WriteLine (L"car number\thours parked\t\amount charge" );
//output values for each array
for (int i = 1; i <= 10; i++ )
Console::WriteLine( L"{0}\t\t{1}\t\t{2}", i. ToString(),
hours[ i ].ToString(), charges[ i ].ToString() );
return 0;
}
this is the question:
A Parking Garage charges a $5.00 minimum fee to park for up to two
hours or less. The Garage charges an additional $0.50 per hour for
each hour or part thereof in excess of two hours. The maximum charge
for any given 24-hour period is $10.00. Assume that no car will be
allowed to park for longer than 24 hours at a time.

Write a program that will compute and print the Parking Charges for
each of 10 Customers who parked their cars in this Garage yesterday.

You should enter at the Console the Hours Parked for each Customer
into an Array,
then calculate and store each customer’s charge in an Array as well.
(hint: Use two parallel arrays; hours and charges).

Jun 27 '08 #1
3 2129
TG*******@gmail.com wrote:
>
using namespace System;

int main(array<System::String ^^args)
That's a syntax error, so it looks like you are using something other
than C++. Maybe a windows group would be a better place to ask.

--
Ian Collins.
Jun 27 '08 #2
TG*******@gmail.com wrote:
errors displayed when i tried o compile my
program:.\project5.cpp(9) : error C4980: '__gc' : use of this
keyword requires /clr:oldSyntax command line option
.\project5.cpp(15) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(20) : error C2061: syntax error : identifier 'hours'

this is my program:
// project5.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^^args)
{
int hours __gc[ 10 ];
int charges __gc[ 10 ];
This looks like "Managed C++", which is a totally different language
once promoted on Windows. Like the compiler says, you have to use the
"/clr:oldSyntax" option when using this old syntax (no longer promoted
:-).
Bo Persson
Jun 27 '08 #3
TG*******@gmail.com wrote:
errors displayed when i tried o compile my program:.\project5.cpp(9) :
error C4980: '__gc' : use of this keyword requires /clr:oldSyntax
command line option
.\project5.cpp(15) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(20) : error C2061: syntax error : identifier 'hours'

this is my program:
// project5.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^^args)
{
int hours __gc[ 10 ];
int charges __gc[ 10 ];

Console::WriteLine( L"Enter the number of hours parked:" );
hours[10] = Int32::Parse( Console::ReadLine() );

if hours <= 2
if ( hours <= 2 )
charges = 5
else
charges = (hours – 2) * .50 + 5.00;

if hours 10
if ( hours 10 )
charges = 10;

Console::WriteLine (L"car number\thours parked\t\amount charge" );
//output values for each array
for (int i = 1; i <= 10; i++ )
Console::WriteLine( L"{0}\t\t{1}\t\t{2}", i. ToString(),
hours[ i ].ToString(), charges[ i ].ToString() );
return 0;
}
this is the question:
A Parking Garage charges a $5.00 minimum fee to park for up to two
hours or less. The Garage charges an additional $0.50 per hour for
each hour or part thereof in excess of two hours. The maximum charge
for any given 24-hour period is $10.00. Assume that no car will be
allowed to park for longer than 24 hours at a time.

Write a program that will compute and print the Parking Charges for
each of 10 Customers who parked their cars in this Garage yesterday.

You should enter at the Console the Hours Parked for each Customer
into an Array,
then calculate and store each customer’s charge in an Array as well.
(hint: Use two parallel arrays; hours and charges).
--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
8
by: inkexit | last post by:
I am a very amatuer c++ programmer and a somewhat accomplished composer. I am trying to write some code that creates 'self similar' melodies from a base melody the user inputs. This musical idea...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.