Thread: Some Simple Code

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Some Simple Code

    Didn't add details. Totally common sense program.

    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std;
    
    int main()
    {
    double mpg;
    double miles;
    double costgas;
    double extra;
    
    	cout<<"Welcome to the Trip Cost Calculator.\n\n";
    	Sleep(1000);
    	while(1){
    		cout<<"\n\nEnter the miles per gallon your car goes on: ";
    		cin>>mpg;
    		Sleep(1000);
    
    			cout<<"\n\nEnter the amount of miles you wish to venture during your trip: ";
    			cin>>miles;
    			Sleep(1000);
    
    				cout<<"\n\nThe miles you wish to venture are "<<miles<<" on a car that goes "<<mpg<<" miles per gallon.\n\n";
    				Sleep(1000);
    
    					cout<<"\n\nEnter the cost of each gallon of gas: ";
    					cin>>costgas;
    					Sleep(1000);
    
    cout<<"The miles you wish to venture are "<<miles<<" on a car that goes "<<mpg<<" miles per gallon."<<" The total cost of the trip will be "<<((miles/mpg)*costgas)<<" dollars before extra expenses.\n\n"; 
    
    Sleep(1000);
    cout<<"Enter the extra expenses you will encounter during the trip: ";
    cin>>extra;
    Sleep(1000);
    cout<<"\n\nThe total cost will be "<<((miles/mpg)*costgas)+extra<<" dollars. Hopefully, this amount is very low and you will have lots of fun at your destination! Have fun!\n\n";
    	}
    	}
    By the way, I didn't use strings due to the fact that this is meant to be a learning-program.
    Last edited by YoelWarda; 02-20-2010 at 10:04 PM.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    2
    Bunch of updates on it for more user-friendly use.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    What? Is there supposed to be a question you're asking? Or are you trying to make a "tutorial"-type thing?

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    What's with the crazy indentation and lack of spaces?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Code:
    int answer = 42;
    Didn't add explanation. Totally common sense reply.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    Meaning of life

    Perhaps google douglas adams 42 may serve to explain...? Edit.. O i see the op did not post answer equals 42, haha nice...
    Last edited by rogster001; 02-21-2010 at 02:51 AM.

  7. #7
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by iMalc View Post
    Code:
    int answer = 42;
    Didn't add explanation. Totally common sense reply.
    Quote Originally Posted by rogster001 View Post
    Perhaps google douglas adams 42 may serve to explain...? Edit.. O i see the op did not post answer equals 42, haha nice...
    Yes, he's a clever one.

    Quote Originally Posted by http://www.jayssite.com/stuff/life/life.html
    The answer to life, the universe and everything is 42.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 11-23-2005, 08:53 AM
  2. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Windows Programming
    Replies: 0
    Last Post: 10-14-2002, 01:29 PM
  3. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  4. Simple Code, looking for input.
    By Alien_Freak in forum C Programming
    Replies: 3
    Last Post: 03-03-2002, 11:34 AM