473,326 Members | 2,168 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,326 software developers and data experts.

parking garage calculator

hi all...i am stuck again with a simple program...
I am supposed to create a parking garage rate calc that follows the
rules up to 3 hours its 2 bucks, after that for its fifty cents. Max
charge for a day can be 10 bucks.

out of everything my taecher has said to do, one line of his
instructions i do not understand: Create four objects of class parking
and initialize them with customer specified parking
hour durations. (Feel free to use an array of objects, if you know how.
However you will
not receive any extra credit for it.)

that and he wrote the int main() portion of the program and i am not
sure how I am supposed to tie it with my part of the program. Please
help...thanks!

Feb 15 '06 #1
7 6613

<vg*****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
hi all...i am stuck again with a simple program...
I am supposed to create a parking garage rate calc that follows the
rules up to 3 hours its 2 bucks, after that for its fifty cents. Max
charge for a day can be 10 bucks.

out of everything my taecher has said to do, one line of his
instructions i do not understand: Create four objects of class parking
and initialize them with customer specified parking
hour durations. (Feel free to use an array of objects, if you know how.
However you will
not receive any extra credit for it.)

that and he wrote the int main() portion of the program and i am not
sure how I am supposed to tie it with my part of the program. Please
help...thanks!


Do you know how to define a class? If so, define a class called parking.
You probably want to make a constructor for it that accepts the hours to
park, according to the instructions you quoted. Can you do that?

Do you know how to declare a variable of a given type? If so, then declare
four of them in your main function.

If you can't do these things, then I suspect you're not attending classes,
or not reading your textbook(s). If you can do these things, then what's
the problem you're having?

We're not here to simply do your homework for you.

-Howard


Feb 15 '06 #2
Hi,
Usually help is not provided here for Home Works.

vg*****@gmail.com wrote:
Create four objects of class parking
and initialize them with customer specified parking
hour durations. Four separate objects of the class parking (here refered to as
Class_Parking): -

Class_Parking Cust1 = {"Some data here - for initialization"};
Class_Parking Cust2 = {"Some data here - for initialization"}
Class_Parking Cust3 = {"Some data here - for initialization"}
Class_Parking Cust4 = {"Some data here - for initialization"}

(Feel free to use an array of objects, if you know how.
However you will
not receive any extra credit for it.)
Array of objects: -

Class_Parking Cust[4] = {
Class_Parking("Some data here - for initialization Cust1"),
Class_Parking("Some data here - for initialization Cust2"),
Class_Parking("Some data here - for initialization Cust3"),
Class_Parking("Some data here - for initialization Cust4")
}

that and he wrote the int main() portion of the program and i am not
sure how I am supposed to tie it with my part of the program. Please
help...thanks!


No one can help you with this part, unless you let us look at both what
your teacher said and what you have written. In fact the only way you
can encourage others to help you is to show what code you have written
i.e. what attempt you have already made.

O.O

Feb 15 '06 #3
err im an idiot...i forgot to post the code i wrote

parking.h
#include<iostream>

class parking
{
public:
parking();
void set_hour(float);
void calculate_charge();
float get_hour();
float get_charge();

private:
float charge,hour;

};
parking.cpp

#include<iostream>
#include<string>
#include "parking.h"

using std::cout;
using std::cin;
using std::endl;
using std::string;


parking::parking()
{
charge = 0;
hour = 0;
}

void parking::set_hour(float a)
{
charge = a;

}

void parking::calculate_charge()
{
if (hour <= 3 )
charge == 2;
else charge = (.5 * (3 - hour)) + 2;

if ( hour >= 24 )
charge == 10;
}

float parking::get_hour()
{
return hour;
}

float parking::get_charge()
{
return charge;
}

int main()
{

float n1,n2,n3,n4;

cin>>n1;
cout<<n1;
cin>>n2;
cin>>n3;
cin>>n4;
cout<<" "<<n2<<" "<<n3<<" "<<n4;

return 0;
}

Feb 15 '06 #4
and easy on getting pissed off howard...im not here to ask for
answers...i just want pointers. I have been writing code for a long
time...but I learned myself and never learned the terminology for this
stuff. I can make a program that follows his reqz easily but when I do
that, I tend to not include certain instructions he asks for, and thus
I lose points.

I just forgot to post my code...sorry...thanks for the help though!
(and I understand your frustration if i was trying to leech)

Feb 15 '06 #5
Your class parking - does not have a constructor. From the wording of
your teachers statements - it may imply that you are required to have a
constructor in there.

Is this main() function yours - or your teachers. If its your
teachers, then I expect you teacher wants you to have a constructor for
the class parking. Then initialize four objects (or an array of
objects) as I had mentioned in my previous post with n1, n2 ….
Respectively.

O.O.

Feb 15 '06 #6
yeah that main() function is the teachers...thanks

Feb 15 '06 #7

<vg*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
err im an idiot...i forgot to post the code i wrote

parking.h
#include<iostream>

class parking
{
public:
parking();
void set_hour(float);
void calculate_charge();
float get_hour();
float get_charge();

private:
float charge,hour;

};
parking.cpp

#include<iostream>
#include<string>
#include "parking.h"

using std::cout;
using std::cin;
using std::endl;
using std::string;


parking::parking()
{
charge = 0;
hour = 0;
}

void parking::set_hour(float a)
{
charge = a;

}

void parking::calculate_charge()
{
if (hour <= 3 )
charge == 2;
The == symbol is the boolean comparison "equal to". To assign a value in
c++, use just one = sign, not two.
else charge = (.5 * (3 - hour)) + 2;

That can't be right. Did you mean "(hour -3)"? If hour is greater than 3,
then your computation will produce negative results.
if ( hour >= 24 )
charge == 10;
Again, use =, not ==.

}

float parking::get_hour()
{
return hour;
}

float parking::get_charge()
{
return charge;
}

int main()
{

float n1,n2,n3,n4;

cin>>n1;
cout<<n1;
cin>>n2;
cin>>n3;
cin>>n4;
cout<<" "<<n2<<" "<<n3<<" "<<n4;


I assume you're supposed to create four parking variables here, and pass
these four floats above as the number of hours for the four parking objects
(either to a constructor or to your set_hour function. Then you can use
cout to display the results of calling get_charge for each object.

return 0;
}

Feb 15 '06 #8

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

Similar topics

6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
3
by: Paul | last post by:
I want to make a simple calculator program but dont know where to get started. This is not GUI but a simple terminal program. It would get input like this Enter number: 5 + 10
3
by: quilkin | last post by:
Hi When I use the WM_QUERYENDSESSION event to prevent closing of my app when Windows is shut down, I get the 'windows forms parking window' appearing which is very confusing for users. Any ideas...
2
by: vgame64 | last post by:
hi all...i am stuck again with a simple program... I am supposed to create a parking garage rate calc that follows the rules up to 3 hours its 2 bucks, after that for its fifty cents. Max charge...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
19
by: TexasNewbie | last post by:
This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number. //GUI Calculator Program import javax.swing.*; import...
2
by: cpaucar15 | last post by:
I have this homework and all help will be apreciated The Putdentsinem Parking Garage contains a single lane that holds up to 7 cars. Cars arrive at the south end of the ...
3
by: itsmichelle | last post by:
This is a very primative code of a java swing calculator. I have assigned all the number buttons and the operator buttons and I can add, subtract, multiply, and divide two numbers together. However,...
3
by: mandy335 | last post by:
public class Calculator { private long input = 0; // current input private long result = 0; // last input/result private String lastOperator = ""; // keeps track of...
1
by: borla123 | last post by:
Hi- I'm trying to make an application that computes the fee for parking a car in a parking garage. The user should provide the Time In: and Time Out: values by using DateTimePickers. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.