New to Programming and Need Help

This is a discussion on New to Programming and Need Help within the C++ Programming forums, part of the General Programming Boards category; Hey Everyone this is my first post so I'll get the Intro's out of the way. I'm Kendra and I'm ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    New to Programming and Need Help

    Hey Everyone this is my first post so I'll get the Intro's out of the way. I'm Kendra and I'm 21 years old and I'm a new Computer Programming Major. I'm halfway through my first semester as this major. I spent 2 years in College as a Nursing Major only to find out , after my Mothers death, that I do not want to be a Nurse lol I've always loved computers but everything that I know up to this point is self taught. I live in a small town and no one here does this kind of stuff so I'm somewhat on my own. I've been doing well in my classes (which are all ONLINE) but, C++ has been somewhat of a Pain in my Butt lol My other Programming classes are great.

    SO, here is my problem. I'm having to create a program using While loops. The purpose of the program is to calculate monthly car payments for the user. I'm not allowed to use any Global Variables. I'm also not allowed to use functions so I have to use a Linear-straight-line program. My problem lies in the monPayment I keep getting this error.* error C2064: term does not evaluate to a function taking 1 arguments* I'm confused as to how I would get the monPayments to calculate correctly, given that the number of months (noMonths) has to be either 24, 36, 48 & 60.

    My output should eventually look something like this;

    Vehicle Price : 99999.99
    Trade in Value : 99999.99
    Down Payment : 99999.99
    _______________________
    Loan Amount : 99999.99

    Annual Interest Rate 99.99%


    Monthly Payment Options
    24 mo 99999.99
    36 mo 99999.99
    48 mo 99999.99
    60 mo 99999.99




    #include <iostream> //Access Cout
    #include <cmath> //Access Power Functions
    #include <iomanip> //Access Manipulators

    using namespace std;

    int main()

    {
    //Input Variables.

    float price; //Price of vehicle
    float downPayment; //Down Payment
    float tradeIn; //Trade in for vehicle
    float loanAmt; //Loan Amount (calculated)
    float annualIntRate; //Annual Interest Rate (fraction)
    float annualIntPercent; //Annual Interest Rate (percent)
    float monIntRate; //Monthly Interest Rate (fraction)
    int noMonths; //Number of MonthlyPayments
    (24,36,48 & 60)
    float monPayment; //Monthly Payment

    //Prompt User for Input.

    // Get Price.
    cout << " Enter Price of Vehicle: ";
    cin >> price;
    // Get Interest Rate.
    cout << " Enter Annual Interest Rate; ";
    cin >> annualIntRate;
    // Get Down Payment.
    cout << " Enter Down Payment in dollars and cents: ";
    cin >> downPayment;
    // Get Trade In .
    cout << "Enter trade-in in dollars and cents: ";
    cin >> tradeIn;


    // Calculations
    // Formulas
    //

    while(price >= 50000.00);

    {
    if ((tradeIn >= price)&&(downPayment >= price - tradeIn))
    loanAmt = price - tradeIn - downPayment;
    monIntRate = annualIntRate / 12.0;
    annualIntPercent = annualIntRate * 100.0;
    loanAmt= price - downPayment - tradeIn;
    monPayment=(loanAmt*monIntRate)(1.0 -(1 + monIntRate)-noMonth);


    //Output results
    cout << fixed << "Price of Vehicle: " << setprecision(2) << price << endl << "Trade in Value : " << setprecision(2) << tradeIn << endl
    << "Down Payment : " << setprecision(2) << downPayment << endl << "----------------------" << endl << "Loan Amount : " << setprecision(2) <<loanAmt <<endl << "Interest Rate : " << setprecision(2) << annualIntPercent << "%" << endl;

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    << !! Posting Code? Read this First !! >>
    So rather than read that, and post something readable, your work-around hack was to remove all the closing braces and post an unreadable mess.

    READ the link, and repost your actual code.

    Not some hatchet job just to get past the code check filter designed to make life easier for the rest of us!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    Sorry

    Didn't mean to upset anyone. That was my very first post. My bad.

    Code:
    #include <iostream>				//Access Cout
    #include <cmath>				//Access Power Functions
    #include <iomanip>				//Access Manipulators
    
    using namespace std;
    
    int main()
    
    {
    	//Input Variables.
    
    	float price;				//Price of vehicle
    	float downPayment;			//Down Payment
    	float tradeIn;				//Trade in for vehicle
    	float loanAmt;				//Loan Amount (calculated)
    	float annualIntRate;		//Annual Interest Rate (fraction)
    	float annualIntPercent;		//Annual Interest Rate (percent)
    	float monIntRate;			//Monthly Interest Rate (fraction)
    	int noMonths;				//Number of Monthly Payments (24,36,48 & 60)
    	float monPayment;			//Monthly Payment
    
    	//Prompt User for Input.
    
    	// Get Price.
    	cout << " Enter Price of Vehicle: ";
    		 cin >> price;
    	// Get Interest Rate.
    	cout << " Enter Annual Interest Rate; ";
    		 cin >> annualIntRate;
    	// Get Down Payment.
    		 cout << " Enter Down Payment in dollars and cents: ";
              cin >> downPayment;
    	 // Get Trade In .
    		  cout << "Enter trade-in in dollars and cents: ";
    		  cin >> tradeIn;
    		
    
    		// Calculations
    			// Formulas
    		   // 
    
    	 while(price >= 50000.00);
    
    		 {
    	                          if ((tradeIn >= price)&&(downPayment >= price - tradeIn))
    				 loanAmt = price - tradeIn - downPayment;
    			monIntRate = annualIntRate / 12.0;
    			annualIntPercent = annualIntRate * 100.0;
    			loanAmt= price - downPayment - tradeIn;
    			
    		 }
    
    		 
    		 
    		 //Output results
    
        cout << fixed << "Price of Vehicle:		"<< setprecision(2) << price       << endl
    				  << "Trade in Value  :		"<< setprecision(2) << tradeIn     << endl 
    				  << "Down Payment    :	    "<< setprecision(2) << downPayment << endl
    				  << "----------------------------------------"                << endl
    				  << "Loan Amount	  :		" << setprecision(2) <<loanAmt     << endl
    
    				  << "Interest Rate   :		" << setprecision(2) << annualIntPercent << "%" << endl;

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    107
    Could you please show us the line where the error is? I don't think this code is complete as I am scanning for a brace ending main() and not finding it. Is there more to this program?

    Welcome to the forum; I hope you will come back often as you progress.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    Thank you!

    Thank You for your generous reply!

    Yes, there is more to the code, I did not paste my return 0; with the return brace ( } ). And Now that I look, I didn't post a copy of the line with the error on my second attempt to paste the code on here. I was testing the program without the equation that keeps giving me the error. The program is running perfectly until it gets to the line in bold.

    Thanks again!

    Code:
    //Output results
    
        cout << fixed << "       Honest Dave's Used Cars  " << endl
    
    				  << "Price of Vehicle:		"<< setprecision(2) << price       << endl
    				  << "Trade in Value  :		"<< setprecision(2) << tradeIn     << endl 
    				  << "Down Payment    :	    "<< setprecision(2) << downPayment << endl
    				  << "----------------------------------------"                << endl
    				  << "Loan Amount	  :		" << setprecision(2) <<loanAmt     << endl
    
    				  << "Interest Rate   :		" << setprecision(2) << annualIntPercent << "%" << endl
    
    				  << "		  Monthly Payment Options   " endl;
        cout << fixed << "24 Months:	" << setprecision(2) 
    				  << (loanAmt * monIntRate)(1.0 - (1 + monIntRate) - 24) << endl;    //error C2064: term does not evaluate to a function taking 1 arguments
      
    
    
    
    
    
    cin.get();
    cin.get();
    return 0;
    
    }
    My professor gave us that exact formula to use in our program to find the monthly payment options. The purpose of that line is to calculate what the users payments would be for 24 months. It needs to also do the same for 36, 48 & 60 months, however; I can't get it to run properly for 24 months.

  6. #6
    The Dragon Reborn
    Join Date
    Nov 2009
    Location
    Dublin, Ireland
    Posts
    629
    (loanAmt * monIntRate)(1.0 - (1 + monIntRate) - 24)
    I belive that is where your problem is.

    if you evaluate
    Code:
    (loanAmt * monIntRate)  //assuming you get 12
    then eval this:
    Code:
     (1.0 - (1 + monIntRate) - 24) // assuming 13
    so now we have
    Code:
    cout <<(12) (13) << endl; //with your error code: I assume that the compiler thinks you mean to call a function that takes an int
    //but it has no idea what function you intend to call.
    the compiler is like what the hell?
    It could also think you were calling a function, hence the error code. like () you are calling 2 functions, and passing a value, but what function do you want
    to call? You haven't specified.. strlen, strcat, you get the point
    You probably have to divide or multiply, or missing some operator.
    That's the problem I think, check the formula again.
    luck
    Last edited by Eman; 10-26-2010 at 08:33 AM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21