You have been asked to write a program to calculate the mortgage rate for your five clients. The computation process itself can be conveniently done by a web service, as demonstrated by the following code: #include "soapH.h" // include the generated proxy #include <string> #include <iostream> #include <stdlib.h> #include "MortgageSoap.nsmap" //include namespace map using namespace std; int main() { struct soap *soap = soap_new(); //new soap instance _ns1__GetMortgagePayment* myData = new _ns1__GetMortgagePayment; //input class instance, determined from mortgage.h _ns1__GetMortgagePaymentResponse* myResult = new _ns1__GetMortgagePaymentResponse; //output class instance int theName;//years double theName2[4];//interest, loan amount, annual tax, annual insurance cout<<"Years: "; cin>>theName; cout<<"Interest: "; cin>>theName2[0]; cout<<"Loan amount: "; cin>>theName2[1]; cout<<"Annual tax: "; cin>>theName2[2]; cout<<"Annual insurance: "; cin>>theName2[3]; myData->Years=theName; myData->Interest=theName2[0]; myData->LoanAmount=theName2[1]; myData->AnnualTax=theName2[2]; myData->AnnualInsurance=theName2[3]; if (soap_call___ns1__GetMortgagePayment(soap, NULL, NULL, myData, myResult) == 0) { //soap method for getting mortgage quote, determined from mortgage.h ns1__MortgageResults* results = new ns1__MortgageResults; results=myResult->GetMortgagePaymentResult; cout<<"\nMonthly principal and interest: "<< results->MonthlyPrincipalAndInterest<<"\n"; cout<<"Monthly tax: "<<results->MonthlyTax<<"\n"; cout<<"Monthly insurance: "<<results->MonthlyInsurance<<"\n"; cout<<"Total payment: "<<results->TotalPayment<<"\n"; } else{ soap_print_fault(soap, stderr); } soap_destroy(soap); //destroy soap instance system("pause"); return 0; } The complete project of the above code is available at VLT (gsoapMortgage.rar). Based on the above code, your program should read in the basic information from keyboard for these five clients, store the information in an array of struct, use the web service to obtain the mortgage result, and print out the mortgage information to computer screen as well as an output data file (mortgage.dat). The struct of client information should contain the following fields: Years (data type: int) Interest (data type: float; unit: percentile) Loan_amount (data type: float; unit: dollar) Annual_tax (data type: float; unit: dollar) Annual_insurance (data type: float; unit: dollar) The name of the above struct is ClientInfo. The detailed information for the five clients is as follows: Client1: Years (30), Interest (4.5), Loan_amount(300000), Annual_tax(3000), Annual_insurance(1000) Client2: Years (15), Interest (4.5), Loan_amount(300000), Annual_tax(3000), Annual_insurance(1000) Client3: Years (30), Interest (3.5), Loan_amount(200000), Annual_tax(2000), Annual_insurance(800) Client4: Years (20), Interest (3.5), Loan_amount(200000), Annual_tax(2000), Annual_insurance(800) Client5: Years (30), Interest (4.5), Loan_amount(180000), Annual_tax(2000), Annual_insurance(700) You should create another struct for mortgage result, which contains the following fields: MonthlyPrincipalAndInterest (data type: float) MonthlyTax (data type: float) MonthlyInsurance (data type: float) TotalPayment (data type: float) The name of the above struct is MortgageResult. The program should have a while loop or a for loop in the main routine to ask users input the client information through keyboard. In this way, the program has a capability of repeatedly asking for the information in each loop until the information of all the five clients is provided. |
|
|