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 10th, 2010, 03:54 PM
373help_me 373help_me is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 6 373help_me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 7 sec
Reputation Power: 0
General - Need help asap

I need help i am write in a program in c++ that displays the amount of moving violations prompt the user to enter the illegal speed in miles per hour n calculate the fine is $50.00 plus 5$ for each mile per hour the fine the legal limit is 55. if the illegal speed was greater than 70 miles per hour the fine is $ 125 plus $10 for each mile per hour over 70 help me plz this is kill in me

include <iostream>
#include <iomanip>

using namespace std;
int main()
{
const double OVER_SPEED_LIMIT_EACH_MILES = 10.0;
const double SEVENTY_MILES = 125.0;
int speed_over_each_miles,
another_speeder; // 1 if another speeder; 0 if not
double per_hour,
miles,
regular_speed_limit,
per_hour_over,
total;
total = 0.00;
speed_over_each_miles = 0;

cout << setprecision(2)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);
do
{
// Prompt the user
cout << endl << endl;
cout << "enter miles per hour: ";
cin << per_hour;
cout << "\nEnter speeder miles: ";
cin << miles;

// Calculate the speed
if (per_hour > SEVENTY_MILES)
{
regular_speed_limit = SEVENTY_MILES * miles;
per_hour_over = (per_hour - SEVENTY_MILES) * OVER_SPEED_LIMIT_EACH_MILE * miles;
}
else
{
regular_speed_limit = per_hour * miles;
per_hour_over = 0.00;

// Display the speed
cout << endl << endl;
cout "REGULAG SPEED LIMIT PER HOUR OVER" ;
cout << endl << setw(11) << regular_speed_limit
<< set(14) << per_hour_over << endl;
cout << "-----------------------------------" <<endl ;

// Ask the user if he/she wants to continue
cout << endl << endl;
cout << "Do you want to process another speeder? " << endl;
cout << "enter 1 for yes or 0 for no: ";
cin >> another_speeder;
}
while (another_speeder);

// Print the total

cout << endl << endl;
cout << "total for " << speeder_over_each_miles
<< " speeder is " << total << endl;



return 0;
}

Reply With Quote
  #2  
Old February 11th, 2010, 11:14 AM
Nether Nether is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 13 Nether User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 43 sec
Reputation Power: 0
Quote:
Originally Posted by 373help_me
I need help i am write in a program in c++ that displays the amount of moving violations prompt the user to enter the illegal speed in miles per hour n calculate the fine is $50.00 plus 5$ for each mile per hour the fine the legal limit is 55. if the illegal speed was greater than 70 miles per hour the fine is $ 125 plus $10 for each mile per hour over 70 help me plz this is kill in me

include <iostream>
#include <iomanip>

using namespace std;
int main()
{
const double OVER_SPEED_LIMIT_EACH_MILES = 10.0;
const double SEVENTY_MILES = 125.0;
int speed_over_each_miles,
another_speeder; // 1 if another speeder; 0 if not
double per_hour,
miles,
regular_speed_limit,
per_hour_over,
total;
total = 0.00;
speed_over_each_miles = 0;

cout << setprecision(2)
<< setiosflags(ios::fixed)
<< setiosflags(ios::showpoint);
do
{
// Prompt the user
cout << endl << endl;
cout << "enter miles per hour: ";
cin << per_hour;
cout << "\nEnter speeder miles: ";
cin << miles;

// Calculate the speed
if (per_hour > SEVENTY_MILES)
{
regular_speed_limit = SEVENTY_MILES * miles;
per_hour_over = (per_hour - SEVENTY_MILES) * OVER_SPEED_LIMIT_EACH_MILE * miles;
}
else
{
regular_speed_limit = per_hour * miles;
per_hour_over = 0.00;

// Display the speed
cout << endl << endl;
cout "REGULAG SPEED LIMIT PER HOUR OVER" ;
cout << endl << setw(11) << regular_speed_limit
<< set(14) << per_hour_over << endl;
cout << "-----------------------------------" <<endl ;

// Ask the user if he/she wants to continue
cout << endl << endl;
cout << "Do you want to process another speeder? " << endl;
cout << "enter 1 for yes or 0 for no: ";
cin >> another_speeder;
}
while (another_speeder);

// Print the total

cout << endl << endl;
cout << "total for " << speeder_over_each_miles
<< " speeder is " << total << endl;



return 0;
}




Okay there is a lot of problems that I have noticed. First is #include <iostream> you have forgotten the #. The next one is half your your cin statements have wrong arrows. Use >> not <<. I currently can't test this at the moment but I do not think you need #include <iomaniop>.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Need help asap


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap