 |
|
|
 |
New Member
|
|
Sep 23, 2007, 03:36 PM
|
|
Internet Usage Calculator Prorgam
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
|
|
 |
Computer Expert and Renaissance Man
|
|
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.
|
|
 |
New Member
|
|
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
|
|
 |
Computer Expert and Renaissance Man
|
|
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.
|
|
 |
Junior Member
|
|
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.
|
|
 |
New Member
|
|
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
|
|
 |
Junior Member
|
|
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.
|
|
 |
Computer Expert and Renaissance Man
|
|
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
|
|
 |
New Member
|
|
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
|
|
 |
Junior Member
|
|
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
|
|
 |
New Member
|
|
Sep 23, 2007, 07:14 PM
|
|
Haha... I wish I could make C++ look that easy...
Thanks!
Shane
|
|
 |
Junior Member
|
|
Sep 23, 2007, 07:20 PM
|
|
Lol, its why I chose delphi. Its a lot neater and just as powerful :P
No problem, Shane.
|
|
 |
Computer Expert and Renaissance Man
|
|
Sep 24, 2007, 05:20 AM
|
|
I'm confused are you coding in C++ or Visual Basic?
|
|
 |
New Member
|
|
Sep 24, 2007, 08:14 AM
|
|
visual c++... some of the stuff is added just for the class learning process (descriptions /* */)
|
|
 |
Computer Expert and Renaissance Man
|
|
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.
|
|
 |
New Member
|
|
Sep 24, 2007, 08:24 AM
|
|
Thank you. I'm still learning all the differences and this language, haha.
Thanks again
|
|
Question Tools |
Search this Question |
|
|
Add your answer here.
Check out some similar questions!
How to create a calculator in VB 6.0
[ 11 Answers ]
Hi! I'm Naveen
I have a school project.
Its 2 create a calculator in VB 6.0 using just basic or easy methods.
Help me with the coding.
Also I just need a simple coding , not a complex one or my teacher won't accept.
Help!!
TI-84 Plus Calculator
[ 1 Answers ]
This is sort of a math question and it isn't. I just bought this calculator yesterday, and the book that came with it does not tell me how to program the Quadratic formula as well as other equations into this calculator. And someone I know in my class has the same one and told me that this can be...
Software to Track Internet Data Transfer & Usage
[ 17 Answers ]
I want to get a free software to manage my ADSL connection at home, which will tell me the amount of data transferred while I am on net, both sent and received. It will also keep monthly records on each time log-in basis, so that I can get my usage data. It should be absolutely a freeware, as I...
How to do e-0.05 on a calculator
[ 5 Answers ]
Hi there,
What are the exact steps I press on a calculator to do the following: -
40e-0.05
I keep getting the wrong answer? Any help is appreciated
View more questions
Search
|