For this assignment you\'re to write a program that grants or denies a credit ca
ID: 3796559 • Letter: F
Question
For this assignment you're to write a program that grants or denies a credit card to the user. In order for the user to qualify for this exclusive piece of plastic, he/she will first have to enter some items of data. Then the program will evaluate the input, and display a message with the user's good (or bad) fortune. Here are a few more details regarding the functions you'll write for this program: This function prompts the user for the number of years the user has spent at his/her current job. The hourly wage and the number of hours per week main will then pass this information along as input to the CheckQualify function, which returns a true or false value; main will then use this value as an argument to the DispQualify function. This function will receive as input the number of years the user has spent at his/her current job. The hourly wage and the number of hours per week. Then the function CalcSalary is called to derive the full annual salary of the user. In order to qualify for the credit card, the user must have worked at their current job for at least two years, and make at least $17,000 per year. CheckQualify will return a value of true to the caller if the user qualifies, false if not. This function will receive as input the hourly pay and number of hours worked per week. Then it will calculate the total annual salary, and return this value to the caller. This function is called from main and receives a boolean value as input, with true meaning that the user qualifies for the card, and false meaning the card is to be denied. Thus, this function will display the -approved- or -denied- message to stdout. As usual, the most important thing to do first is to thoroughly understand the problem! Think of what the user should sec on the screen. What prompts will appear and what the user will enter from the keyboard. Make sure you're clear on the program flow -- which functions are being called when, what their inputs and return values are. Consider each function independently of the other functions... As individual functions, they each have their own tasks that they must perform. Sketch out on a piece of paper the sequence of steps each function will have to take in order to complete those tasks. In other words, you should first figure out what you're going to do before you try to do it! If you do that, you can save yourself loads of time and frustration. Then when you think you have a strong understanding, you're probably ready to start writing the code. If you're still a little fuzzy on functions, you can study your notes, read the book and write some throw-away code before you begin; all of these activities will help you feel more comfortable with the material. Note that in this particular program, you have functions calling functions! That's not a problem, because functions always return to their callers. For a graphical illustration of the hierarchy of function calls and flow of data, look at the structure chart for this program (remember, structure charts are read from top-to-bottom, left-to-right). Where will you put your code? Create a subdirectory called HW05 and save your code in a file called cardqualify.cpp in that subdirectory. Good luck!Explanation / Answer
solution
#include<stdio.h>
#include<iostream>
using namespace std;
bool checkqualify(float noyears,float hourwage,float nohoursweek);
float calcsalary(float hourlywage,float noofhoursweek);
void dispqualify(bool flag);
int main()
{
float noofyears;
float hourlywage;
float noofhoursperweek;
cout<<"enter no of years spent in your current job"<<endl;
cin>>noofyears;
cout<<"enter the hourly wage "<<endl;
cin>>hourlywage;
cout<<"enter the no of hours per week"<<endl;
cin>>noofhoursperweek;
bool flag= checkqualify(noofyears,hourlywage,noofhoursperweek);
dispqualify(flag);
}
bool checkqualify(float noyears,float hourwage,float nohoursweek)
{
if(noyears>=2)
{
float salary=calcsalary(hourwage,nohoursweek);
float yearlysalary=salary*52;
cout<<"yearly salary"<<yearlysalary<<endl;
if(yearlysalary>=17000)
{
return true;
}
else
return false ;
}
}
float calcsalary(float hourlywage,float noofhoursweek)
{
//to check for only non negative
if(hourlywage>0&&noofhoursweek>0)
{
float salary=hourlywage*noofhoursweek;
return salary;
}
else
return 0;
}
void dispqualify(bool flag)
{
if(flag==true)
{
cout<<" eligible to loan approved"<<endl;
}else
cout<<"loan denied"<<endl;
}
output
enter no of years spent in your current job
3
enter the hourly wage
250
enter the no of hours per week
10
yearly salary130000
eligible to loan approved
--------------------------------
Process exited after 12.28 seconds with return value 0
Press any key to continue . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.