| | |
program help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2004
Posts: 12
Reputation:
Solved Threads: 0
i have been trying to incorporate various element into this mortgage calculation program. it is supposed to present the three options from the array or prompt you to enter your own rates. my structure with the public and private sections are out of place. i need help streamlining this and resolving its massive errors from my faulty logic.
C++ Syntax (Toggle Plain Text)
#include <iostream.h> double MonthlyPayment (double amount, double rate, int months); int GetChoice(void); int main( ); //struct Choice static const Choice menu[] = ( 7, 5.35, 15, 5.5, 30, 5.75 ); //if i put the colon before menu= lots of errors { int term; double rate; void Show() { std::cout << term << " years @ " << rate << '%' << std::endl; } }; int main(); { size_t selection; do { for ( size_t i = 0; i < sizeof menu / sizeof *menu; ++i ) { std::cout << '(' << i << ") "; menu[i].Show(); } std::cout << "Selection ? "; std::cin >> selection; } while ( selection >= sizeof menu / sizeof *menu ); std::cout << "Your selection:\n"; menu[selection].Show(); return 0; } { double months, amount, rate; int option; //create a loop while((option = GetChoice()) == 1) { //option = GetChoice(); cout << "Enter the loan amount: "; cin >> amount; cout << "Enter the interest rate (X.Y): "; cin >> rate; cout << "Enter the length of the loan in months : "; cin >> months; //this line will generate a loss of data warning cout << "\tYour monthly payment is $ "<<MonthlyPayment(amount, rate, months)<<endl; } return 0; } int GetChoice(void) { int num; cout << endl; cout << "1. Calculate your monthly payment on the loan." << endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl; cout << "0. Exit the program" << endl; cout << "Press 1 to procede : "; cin >> num; return num; } double MonthlyPayment (double amount, double rate, int months) { //declare a local variable to be used for calc's and to hold return value, not function name! double monthPayment; // do the calc's //amount, months and rates values declared in prototype parameters, no need to define local variables monthPayment = (amount * months) / rate /1200; return monthPayment; //return the double }
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the C++ Forum
- Previous Thread: Visual C++
- Next Thread: Cd-drive
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






