473,813 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6648

<vg*****@gmail. com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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.c om 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<iostre am>

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

private:
float charge,hour;

};
parking.cpp

#include<iostre am>
#include<string >
#include "parking.h"

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


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

void parking::set_ho ur(float a)
{
charge = a;

}

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

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

float parking::get_ho ur()
{
return hour;
}

float parking::get_ch arge()
{
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...than ks

Feb 15 '06 #7

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

parking.h
#include<iostre am>

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

private:
float charge,hour;

};
parking.cpp

#include<iostre am>
#include<string >
#include "parking.h"

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


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

void parking::set_ho ur(float a)
{
charge = a;

}

void parking::calcul ate_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_ho ur()
{
return hour;
}

float parking::get_ch arge()
{
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
7309
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.... #include <stdio.h> #include <stdlib.h>
3
5219
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
8689
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 how to stop this?
2
841
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 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...
24
6348
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 have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
19
4035
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 java.awt.*; import java.awt.event.*; import java.io.*;
2
4612
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 garage and leave from the north end. If a customer arrives to pick up a car that is not the northenmost, all cars to the north of his car are moved out , his car is driven out , and the other cars are restored in the same...
3
11863
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, my teacher wants the operators to follow the algebraic order of operations by chaining multiple operations. Such as, 7 + 4 * 2= 15. The operatorListener is the ActionListener for the operator buttons. Thanks for any help you can give me. ...
3
2898
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 the last operator entered /* Digit entered as integer value i * Updates the value of input accordingly to (input * 10) + i */
1
4329
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 application should calculate the cost of parking in the garage for the specified amount of time. Parking costs three dollars an hour. When calculating the total time spent in the garage, I will ignore the seconds value but the minutes value is treated as a...
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10667
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10407
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10422
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9222
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3885
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.