Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account


  • 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