C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 11th, 2006, 07:42 PM
O_^ O_^ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 O_^ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 29 sec
Reputation Power: 0
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;
}

Reply With Quote
  #2  
Old February 11th, 2006, 09:04 PM
r.3volved r.3volved is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 5 r.3volved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 6 m 49 sec
Reputation Power: 0
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...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Please help with the code :( running out of time!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT