View Full Version : Internet Usage Calculator Prorgam
supperc6c7
Sep 23, 2007, 03:36 PM
Hello,
I am trying to write a program that calculates a person's internet service bill. I am having trouble in two major areas:
The first is that there are three packages the user is instructed to pick, A, B, or C-How do I tell the program to terminate if one of these letters isn't picked?
The other is to how do I do the calculations-package A is 9.95 for ten hours, B is 14.95 for 20 hours, and C is unlimited... I understand the symbols, etc for the calculations... I'm just stuck on how to tell the program what to do if there is 16 hours used and the person has package A... my instructions ask me to tell the user how much the person would save if they switched to say Package B...
I am very, very new to prorgramming,
Thanks in advance,
Shane
ScottGem
Sep 23, 2007, 03:52 PM
You use the IsNull function to test if a value has been entered. You use the Select Case statement to perform an action for different circumstances.
supperc6c7
Sep 23, 2007, 04:45 PM
Thank you so much for your response!
I have looked up these functions and see where they would get the job done but being the beginner that I am I learn from example... could you use one or both of these in a very very short example in c++?
If you are available to chat or message or something I would be up for that as well as I need serious help for this assignment... it is very simple but when you are still learning all the basics yourself it is tough...
Thanks!
Shane
ScottGem
Sep 23, 2007, 05:54 PM
First you posted this in the VB forum. Second, I figured this was for a class assignment. While I'm willing to give you direction, I'm not going to do the work for you. You should be able to find examples or interpret how to use what I gave you.
SabbzR
Sep 23, 2007, 06:24 PM
Hi shane,
Try running your query through Google, I've found lots of examples to help me with code that I am unable to get done, its how I learned to program. I only went to a programming college because I needed a certificate ( :/ ).
I taught myself everything I know, and while I only have the business experience of about 2 years, I have been programming for the last 5 years.
Anyway.. what I like to do, is look for examples to help me... BUT... I write the code MY way - I do not just copy paste because this won't teach you {vulgarity deleted-<>} taking the commands that were used, then incorporating into your own code will allow you to memorise the code for later use.
supperc6c7
Sep 23, 2007, 06:28 PM
I definitely do not want the work done for me... I really am having trouble with all of it. I've searched for the IsNull function but all I seem to find is Access related info... my class notes for this assignment use "dataOK" type syntax but when I use it and use a letter other that what I specify (A, B, or C) it doesn't terminate...
Sorry if it came off as me wanting work done for me, I am diligently trying to figure it out with reference-type help, hence I am here. Otherwise I would've used one of those hire a coder type websites to do the whole thing for me.
Thanks again,
Shane
SabbzR
Sep 23, 2007, 06:31 PM
Although I program in Delphi, have you made sure that the case of the letters is correct?
'A' and 'a' are completely different to a lot of compilers.
Look @ the basics first, then work your way up - it's the best way to debug your applications.
ScottGem
Sep 23, 2007, 06:35 PM
I code in VBA, which is a superset of VB. The IsNull function should work in VB. Its syntax is simple: IsNull(value) it returns a Boolean value
supperc6c7
Sep 23, 2007, 06:53 PM
Okay here is what I have so far, please don't laugh at me. Where would I use the IsNull value? Would you change the way I have the constants/parameters set up?
#include <iostream> /* include standard I/O header */
#include <iomanip>
using namespace std;
int main ()
{ /* begin main function */
/* declare named constants */
const double A = 9.95; /* 10 hours of monthly access provided, additional hours are $2.00 per hour */
const double B = 14.95; /* 20 hours of monthly access provided, additional hours are $1.00 per hour */
const double C = 19.95; /* unlimited access provided */
const double overA = 2.00;
const double overB = 1.00;
const int monthlyhoursMIN = 1;
const int monthlyhoursMAX = 744;
/* input parameters */
char PACKAGE_A, /* patient's package letter */
PACKAGE_B, /* patient's package letter */
PACKAGE_C, /* patient's package letter */
monthlyhours; /* number of hours used in month */
/* calculated variables */
double sum; /* average of the 3 temperatures */
bool dataOK; /* true if all data is valid and */
/* false otherwise */
/* print overall output title */
cout << endl << "==============================================" << endl;
cout << "INTERNET SERVICE PROVIDER BILLING CALCULATOR" << endl;
cout << "==============================================" << endl;
/* read input data from the keyboard */
cout << endl << "Enter Subscription Service -> ";
cin >> PACKAGE_A; PACKAGE_B, PACKAGE_C;
cout << endl << "Enter number of hours used -> ";
cin >> monthlyhours;
/* test for validity of the monthly hours used and */
/* set the data flag appropriately */
dataOK = (PACKAGE_A = A); (PACKAGE_B = B); (PACKAGE_C = C);
dataOK = (monthlyhours >= 0) && (monthlyhours <= 744);
if (dataOK)
{
cout << showpoint << fixed << setprecision (3);
}
else
cout << "test.";
/* print a closing message */
cout << endl << "Program Terminates Normally." << endl << endl;
return (0);
SUMMARY
This program accepts a customer's Internet Service Provider
Subscription Service plan and hours used that month, calculates his
or her bill, and prints a message indicating whether the customer
could have saved money by switching to another subscription package
and how much. Package A (PACKAGE_A) includes 10 hours of monthly access
for $9.95 per month, and additional hours are $2.00 per hour (overA)
for this pacakge. Package B (PACKAGE_B) includes 20 hours of monthly
access for $14.95 per month, and additional hours are $1.00 per hour
(overB) for this pacakge. Lastly, Package C (PACKAGE_C)is $19.95 per
month and unlimited access is provided. Names in parenthesis are named
constants so that the prorgam can be easily changed if new prices
are chosen.
Thank you so much for all of your posts!
Shane
SabbzR
Sep 23, 2007, 07:00 PM
Lol, that's greek to me...
Delphi is a lot easier:
Case PackageChoice of
0:begin // Package A
{Do Something}
Exit; // Exits procedure
End;
1:begin // Package B
{Do Something}
Exit; // Exits procedure
End;
2:begin // Package C
{Do Something}
Exit; // Exits procedure
End;
End;
CalcuateCostsForCustomer.Execute;
That's just an example, I don't know if you can work from it. Lol :P
supperc6c7
Sep 23, 2007, 07:14 PM
Haha... I wish I could make C++ look that easy...
Thanks!
Shane
SabbzR
Sep 23, 2007, 07:20 PM
Lol, its why I chose delphi. Its a lot neater and just as powerful :P
No problem, Shane.
ScottGem
Sep 24, 2007, 05:20 AM
I'm confused are you coding in C++ or Visual Basic?
supperc6c7
Sep 24, 2007, 08:14 AM
visual c++... some of the stuff is added just for the class learning process (descriptions /* */)
ScottGem
Sep 24, 2007, 08:23 AM
Then why did you originally post it in the Visual Basic forum? My answers were based on your using VB.
I've moved it to the C++ forum for you.
supperc6c7
Sep 24, 2007, 08:24 AM
Thank you. I'm still learning all the differences and this language, haha.
Thanks again