undergraduate student. If the answer is n then they do not qualify for financial
ID: 3683787 • Letter: U
Question
undergraduate student. If the answer is n then they do not qualify for financial aid. If the answer is y they are then asked to enter their income level as an integer. If their income is equal to or below $15,000 then they qualify for $1000 in financial aid, but if their income is greater, they only qualify for $500 in financial aid You will be required to write multiple functions for this exercise. You must have at least 4 functions including the main function. One of your non-main functions will ask the application user if the student is an undergraduate or not. The valid answers are y or n. If the answer is y your function needs to return a value that indicates that the student is an undergraduate. If the student enters in n your function needs to return a value to indicate that the student is a graduate student. If the user enters in an invalid value (not y or n) your function needs to output an error message and return a value indicating that the student type is invalid Your function can return either an int or a char (your choice) to indicate the type of the student. If you want to allow a y, Y, n or N as valid input you can do so, but it is not required for this assignment. Another one of your non-main functions will determine the amount of financial aid. The function is only called if the student is an undergraduate. The function needs to ask the application user to enter in the annual income. If the annual income is less than 0 the function needs to output an error message and return an annual income of -1 (to indicate that the aid amount is not valid). If the annual income is 0 or more the function will determine the amount of aid the student gets. The aid value is returned from the function back to the caller. Again, a return value of-1 indicates that the financial aid could not be calculated The third non-main function will display the amount of financial aid for an undergraduate student. The amount of financial aid needs to be passed to the function The main function will call the other functions, starting with the one that gets the student type. If the student is an undergraduate the main function will call the function that calculates the financial aid. If the financial aid value is valid, the main will then call the function that displays the financial aid. If the student is a graduate student the main function needs to display a message saying the student does not qualify for financial aid. The input and output should look similar to this (the bolded parts represent inputs by the user). Here are three sample runs. You also need to test error conditions. Run # 1 Are you an undergraduate student? y [Enter] What is your current yearly income? 15000 [Enter] You qualify for $1000 in financial aid Run #2 Are you an undergraduate student? y [Enter] What is your current yearly income? 15001 [Enter] You qualify for $500 in financial aid. Run # 3 Are you an undergraduate student? n [Enter] You do not qualify for financial aidExplanation / Answer
#include<iostream>
using namespace std;
char isUnderGraduate();
void display(float amount);
float aid();
int main(){
char c = isUnderGraduate();
if(c=='y'){
float amount = aid();
if(amount != -1)
display(amount);
else
cout<<"Amount is invalid"<<endl;
}
else if(c=='n')
cout<<"Student is graduate"<<endl;
else
cout<<"Invalid input"<<endl;
return 0;
}
char isUnderGraduate(){
char c;
cout<<"Are you an undergraduate student? ";
cin>>c;
if(c=='y')
return 'y';
else if(c=='n')
return 'n';
else
return 'i'; // invalid
}
float aid(){
float inc;
cout<<"What is your current yearly income? ";
cin>>inc;
if(inc < 0)
return -1;
else if(inc>=0 && inc <=15000)
return 1000;
else
return 500;
}
void display(float amount){
cout<<"You qualify for $"<<amount<<" in financial aid"<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.