473,395 Members | 1,377 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,395 software developers and data experts.

Run Time Check faliure # 3 it says the variable hours is being used with out being in

1
it says the variable hours is being used with out being initializes
i am using C++ 2005 express edition , I am currently student

Please help me out to find the solution on my code below

# include <iostream>
using namespace std;
# include <string>
int main ()

{


string name;
char package;
const double PKGA = 9.95; //Package A
const double PKGB = 14.95; // Package B
const double PKGC = 19.95;// Package C
double charges,chargesB , save ,hours ;

cout << " Welcome to Internet service provider." << endl;
cout << " Name of the customer? " << endl;
cin >> name;
cout<<"Which package was purchased?" << endl;
cin >> package;

if (package == 'a' || package == 'A')
{
cout << " Enter the hours " << endl;
cin >> hours;
if(hours <= 744)
{

if ( hours >=10)
charges = PKGA + ( hours - 10) * 2;

else
charges = PKGA ;

}
else
cout << " Invalid Hours" << endl;

}





else if (package == 'B' || package == 'b')
{
cout << " Enter the hours " << endl;
cin >> hours;
if(hours <= 744)
{
if (hours >=20)
charges = PKGB + ( hours - 20) * 1;

else
charges = PKGB;
}
else
cout << " Invalid Hours" << endl;
}
else if(package == 'c'||package == 'C')

charges = PKGC;



if (hours <= 744 && (package == 'A' || package == 'a' || package == 'B' || package == 'b' || package =='C' || package =='c'))

{
cout << " Customer Name " << name << endl;
cout << " Package used " << package << endl;
cout << " Amount due is $ "<< charges << endl;
}

else
{
cout << " Invalid Package" << endl;
}



return 0;
}

Thank You
Apr 18 '08 #1
1 1515
jkmyoung
2,057 Expert 2GB
Initialize hours, say to 0.
hours = 0;

Do this right after you declare the variable.

And can some mod move this to the C++ forum? (I don't have permissions for this forum)
Apr 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Valiz | last post by:
Hi, I am updating system time with IRIG time source which sends irregular pulses as shown below 11000011111100111111111111111111....(1-IRIG present and 0-IRIG not present) I need to update...
6
by: Kenneth | last post by:
Hello, I'm having some serious problems debugging a script that I'm trying to make work. I'm working on a form where a user can type in a time (in the format of HH:MM), and another script...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
13
by: Steve Jorgensen | last post by:
Does this sound familliar to anyone? Regardless of the fact that you have been programming in Access for umpteen years, you still are overly optimistic when it comes to estimating time. The...
8
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() {...
0
by: magazine | last post by:
-----Original Message----- From: Steve Holden Sent: 2006Äê4ÔÂ4ÈÕ 20:00 To: DMagazine@163.com Cc: tim@pollenation.net Subject: Re: #286: Py_Initialize faliure if the python24.lib build with...
23
by: mosesdinakaran | last post by:
Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie)
3
by: lucky33 | last post by:
My employer has asked me to create a database that will keep track of the employee attendance. Time off / Time earned, excused / unexcused, etc. At my company from the 6th month of employment to...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
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...

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.