2 Replies - 530 Views - Last Post: 17 January 2009 - 09:41 PM Rate Topic: -----

#1 Viper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 04-January 09

VOID function is not displaying proper output

Post icon  Posted 17 January 2009 - 09:28 PM

If you enter 16000, 3000 .08, .03 & 4.

VOID function should display 317.37 & 354.15.

but it is displaying 0.08 & 0.03.

What am I doing wrong here???????

I need to use a void function to display the monthly car payments


// Displays month car payments
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>

using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;

//function prototype
double calcPayment (double, double, int);
void displayPayment (double, double);

int main ()
{
// declare variables
double carPrice = 0.0;
double rebate = 0.0;
double creditRate = 0.0;
double dealerRate = 0.0;
int term = 0;
double creditPayment = 0.0;
double dealerPayment = 0.0;

// Get input items
cout << "Car Price : ";
cin >> carPrice;
cout << "Rebate : ";
cin >> rebate;
cout << "Credit Union Rate : ";
cin >> creditRate;
cout << "Dealer Rate : ";
cin >> dealerRate;
cout << "Term In Years : ";
cin >> term;

// Call function to calculate payments
creditPayment = calcPayment (carPrice - rebate, creditRate / 12, term * 12);
dealerPayment = calcPayment (carPrice, dealerRate / 12, term * 12);

// Display Payments
displayPayment (creditRate, dealerRate);  
return 0;
// End of main function
}
// ***** Function Definitions *****
double calcPayment ( double prin, double monthRate, int months )
{
// Calculates and returns a month payment
double monthPay = 0.0;
monthPay = prin * monthRate / ( 1 - pow(monthRate + 1, -months));
return monthPay;
//end of calcPayment function
}
void displayPayment (double creditPayment, double dealerPayment)
{
cout << fixed << setprecision (2) << endl;
cout << "Credit Union Payment : $ " << creditPayment << endl;
cout << "Dealer Payment : $ " << dealerPayment << endl;
}




Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: VOID function is not displaying proper output

#2 perfectly.insane  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: VOID function is not displaying proper output

Posted 17 January 2009 - 09:37 PM

I think you're passing the wrong variables to your void function. dealerPayment vs. dealerRate...

This post has been edited by perfectly.insane: 17 January 2009 - 09:44 PM

Was This Post Helpful? 0
  • +
  • -

#3 Viper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 04-January 09

Re: VOID function is not displaying proper output

Posted 17 January 2009 - 09:41 PM

View Postperfectly.insane, on 17 Jan, 2009 - 08:37 PM, said:

I think your passing the wrong variables to your void function. dealerPayment vs. dealerRate...


Sorry, my bad, its been a long day.

Thank You
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1