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); }



LinkBack URL
About LinkBacks


