Thread: Need help with my first program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    2

    Need help with my first program

    enrolled in my first c++ class and have a homework assignment due. my problem is that i declared my variables and wrote what i think is a good start for the program. my problem is that when i enter the information that i want, my actual output does nothing. i cant seem to get my program to do the math it is supposed to. can someone look at this and see what i am missing. this is just part of the project. i want to get on the right track before i write the rest. i just want this to figure the old monthly cost. i use Dev C++. thank you.

    Code:
    
    #include <iostream>
    #include <cstdlib>
    #include <cfloat>
    
    using namespace std;
    
    int main(int argc, char *argv[]) {
    
    
    float CostOfNewCar; //New vehicle price
    float MonthlyMilesDriven; //Mile driven per month
    float NewVehicleMPG; //New vehicles mile per gallon of gas
    float OldVehicleMPG; //Old vehicles miles per gallon of gas
    float CurrentMonthlyCost; //Current monthly cost that a persons spends
    float ProposedMonthlyCost; //Proposed monthly cost that person will spend
    float PriceOfGas; //Enter the current price of gas per gallon
    float NewCarPayment; //New car payment cost
    float OldMonthlyGasExpense; //Old vehicle gas expense per month
    float NewMonthlyGasExpense; //New vehicle gas expense per month
    float OldCarPayment; //Old car payment
    
    // Prompt user for information
    
    cout << "How many mile do you drive a month?:" ;
    cin >> MonthlyMilesDriven;
    
    cout << "Current vehichles MPG :" ;
    cin >> OldVehicleMPG;
    
    cout << "How much is gas per gallon:" ;
    cin >> PriceOfGas;
    
    
    
    
    
    
    
    
    // Calculations
    
    NewCarPayment = CostOfNewCar / 60 ;
    OldCarPayment = 130.00;
    OldMonthlyGasExpense = MonthlyMilesDriven / OldVehicleMPG * PriceOfGas;
    CurrentMonthlyCost = OldMonthlyGasExpense + OldCarPayment;
    
    
    
    
    
    // Output results
    
    cout << "Currently monthly cost: ";
    cin >> CurrentMonthlyCost;
    
    
    
    
    
    
    
    system("pause");
    
    
    return(0);
    
    
    
    
    }
    Last edited by Salem; 09-18-2008 at 10:51 PM. Reason: Restore original - please don't delete your posts as soon as you get an answer, no one else can learn (or contribute)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM