Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works


  • Please log in to reply



    New Member

  • Member
  • Pip
  • 2 posts
I can not get the program work properly. it suppose to .50 per hour and $2 for parking fee.
it is suppose to use the Calculate Charge function. here is my code the program works but if you enter a odd number it will not show decimal.

#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

int _tmain()
int a = 2.00, // Parking Fee
int h, // number of hours parked
int x=1.00, // charged per hour
int t; // total

Console::WriteLine(S"Please enter the # of hours Parked, -1 to quit");
h = Int32::Parse(Console::ReadLine());

while (h != -1){
t= h*x/2 + 2;

Console::WriteLine(S"Your total is {0}",t.ToString());

a= Int32::Parse(Console::ReadLine());
}//end while
return 0;
  • 0





  • Member
  • PipPip
  • 64 posts
Hi jfrazier,

Your problem is that you are using int's for everything. Int's don't calculate or store any fractional values. Try changing your variable types to double.

  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP