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 November 9th, 2004, 09:53 PM
Magial Magial is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: USA, Indiana
Posts: 7 Magial User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 24 sec
Reputation Power: 0
Send a message via ICQ to Magial Send a message via MSN to Magial Send a message via Yahoo to Magial
Help With Small Program

Okay Im just messing around and I decided on calculating
miles per gallon in a car. Ive got the program pretty much
set up, but when I have it ask to input a value, it skips
through most of the program instead of allowing a user to
insert a number. Im a new programmer so bear with my
coding........

Code:
 
// Calculation of Miles Per Gallon
// Version 1.0
// Josh Lardino
#include <iostream>
 
using namespace std; 
 
int pricePerGallon;
int gallons;
int milesPerGallon;
int tripMiles;
 
int main()
{
cout << "|--------------------------------------------|" << endl;
cout << "|	 MPG (Miles Per Gallon) Calculator	 |" << endl;
cout << "|		 Created By: Josh Lardino		 |" << endl;
cout << "|				 Version 1.0				|" << endl;
cout << "|	 Last Updated: November 09, 2004	 |" << endl;
cout << "|--------------------------------------------|" << endl;
 
cout << endl;
cout << endl;
cout << "This program is to calculate the fule mileage of your \n"
"vehicle." << endl;
cout << "What Youll Need: 1) Gas Reciept. 2) Last displayed \n"
"trip mileage of your car." << endl;
cout << endl;
cout << "Follow the next directions to calculate your vehicles \n"
"mileage. Thanks for using this program." << endl;
cout << endl;
cout << endl;
cout << "Take your gas reciept and enter the price per gallon." << endl;
cout << "Enter Price Per Gallon: $";
cin >> pricePerGallon;
cout << endl;
cout << "Now enter in the amount of gas you put into your \nvehicle. (In Gallons)" << endl;
cout << "Enter Gallons of Gas: ";
cin >> gallons;
cout << endl;
cout << "Now enter in the last displayed trip mileage of your \nvehicle. (In miles)" << endl;
cout << "Enter Trip Miles: ";
cin >> tripMiles;
cout << endl;
milesPerGallon = tripMiles / gallons;
cout << "Your car gets " << milesPerGallon << " miles per gallon. \n"
"Thank you again for using this program." << endl;
cout << endl;
cout << endl;
 
return 0;
}

Reply With Quote
  #2  
Old November 10th, 2004, 12:57 AM
Buster77 Buster77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 28 Buster77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Works on my compiler (VC++ 6.0)

Reply With Quote
  #3  
Old November 10th, 2004, 01:35 AM
Magial Magial is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: USA, Indiana
Posts: 7 Magial User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 24 sec
Reputation Power: 0
Send a message via ICQ to Magial Send a message via MSN to Magial Send a message via Yahoo to Magial
Wonder why its not working with mine. Using Visual C++
but when I run the program (f5), I place one value, then
after I press enter, it skips the other two values and just
ends the program.

Reply With Quote
  #4  
Old November 15th, 2004, 02:39 AM
Evoltix Evoltix is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Nebraska
Posts: 14 Evoltix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Evoltix Send a message via Yahoo to Evoltix
I don't know if this will help but you might try declaring your variables within the int main() function since you don't
really need to declare global variables. Other than that your program seems fine and would run. In VC++ 6.0 you might
try closing the workspace and opening a new workspace. Hope any of that helps.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Help With Small Program


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 3 hosted by Hostway