| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Please help with the code :( running out of time!
Hi everyone! At school I was asked to write a program for a "customer service".. however i have a lack on knowlage and the code i wrote doesn't work...
Can u help me? here is the code. #include <iostream> #include <cstdlib> #include <string> using namespace std; int main () { cout << " " << endl; cout << "Enter the number of hours you were connected to the internet:" ; string hours ; cin >> hours ; if (hours < 20) { cout << N=1 << endl; } else { int var; cin >> var; var = 20; int I; cin>> I; cout << I= (hours - var) << endl; cout << "Enter 1 if you are on the standard plan, or 2 if you are on the premium plan:" ; int plan ; cin >> plan ; if ( plan =1 ) { cout << "Fixed monthly charges are $20.00" << endl; } else { cout << "Fixed monthly charges are $25.00" << endl; } cout <<"Additional per hour charges are:" <<(I * .5) << endl; int total; cin >> total; total = (25 + I * .5); if ( plan !=1 ) { cout << "A %10 discount was deducted from you monthly bill!"<< endl; } else { cout << "No discount for Stanard Customer Plan "<< endl; } cout <<"Total monthly charges are" << (total * 90%) << endl; system("PAUSE"); return 0; } |
|
#2
|
|||
|
|||
|
what exactly isn't working??
how about explaining what errors your are recieving... right off the bat I can see that: string hours ; cin >> hours ; if (hours < 20) You are using a string variable to hold hours, and then you are attempting to use it like a number. You seem to be casting variables in output statements instead of before (or not at all...). You are using a single "=" as a comparison operator when you should be using "==". You are multiplying integers by decimals and trying to save them as integers. You need to use the code tags when you paste code and it will keep all your formatting the way it should be. To tell you the truth, there is a lot wrong with that code. A lot of adjustments are needed to get it to compile... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Please help with the code :( running out of time! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|