gpt4 book ai didi

c++ - 带有三个参数的调用函数的问题,一个是 int const

转载 作者:行者123 更新时间:2023-11-28 02:34:24 28 4
gpt4 key购买 nike

<分区>

我发帖是因为我无法弄清楚为什么我的“可用援助总额”没有打印出佩尔助学金、斯塔福德贷款和勤工助学贷款的总额。我已经尝试一次又一次地修复我的功能(我使用了在线资源和引用书中的资源,但我不知道问题是否是我的功能不会被调用,因为没有任何可用的总帮助打印.

其他一切都很好,除了一件事,这真的让我很烦恼,因为无论我做了什么改变,我都处于相同的状态。也没有错误显示。我第一次使用 Microsoft Visual Studio 作为编译器,所以我想知道这是否是问题所在。

这是我的:

#include <iostream>
using namespace std;

double pell_Grant(double); // forward declaration on pell_Grant ( which is a function for calculating pell grant)

double sum(double, int const, double); // declaration for sum function which gives total for the total aid available

int main()
{

double workstudy = 0, pellgrant = 5730, grossincome = 0, Total = 0; // variables
int yes;
int const stafford = 9500; //const declaration
cout << "Lemme Forecast Your FAFSA" << endl;

cout << "Enter your adjusted gross income: " << endl; cin >> grossincome; // input for gross income

if (grossincome >= 30000) // if gross income is higher than 30,000 then print message
{
cout << "Sorry Charlie, your income is too high to run this forecaster!";
return 0;
}

cout << "Can someone claim you as a dependent? [1=yes/0=no]: " << endl; // input to claim dependent or not
cin >> yes;
if (yes == 1) // if 1 for yes is selected then pell grant gets reduced by 750, if 0 or no selected, then program goes by standard procedure
{
pellgrant -= 750;
}

workstudy = 1465; // work study must be nationwide avergae 1,465
if (grossincome >= 19000) // if this condition is met then work study is not met and message is printed as follows...
{
cout << "Your Work-Study Award is not available for your income level" << endl;
workstudy = 0;
}

double foo = pell_Grant(grossincome); // value returned from pell_Grant stored here to give total

Total = sum(workstudy + stafford + pellgrant); // sum function is called and stores result in Total

if (workstudy != 0) // if work study loan isn't more than 19,000 then it will be calculated and printed in next statement
{
cout << "Your Work-Study Award (if available)= " << workstudy << endl;
}
cout << "Your Stafford Loan award (if needed)= " << stafford << endl; // prints stafford loan (const called)
cout << "Your Pell Grant= " << pellgrant << endl; // prints pell grant
cout << "Total Aid Available For You=" << Total << endl; // prints total

return (0);
}


double pell_Grant(double x) // pell_Grant function that calculates pell grant which is assigned 5,730
{
// x is gross income which is assigned 5,730. This is money received that does not need to be repaid.
if ((x > 12000) && (x < 20000)) // statement makes sure adjusted gross is bettween 12000 & 20000
{
double a = x / 1000; // for every 1,000 in adjusted gross income... reduce/subtract 400 from it
a *= 400;
x -= a;
}

if (x > 20000) // check if gross income is more than 20000
{
double a = x / 1000; // for every 1,000 in gross income, subtract 500
a *= 500;
x -= a;
}
return x;
}


double sum(double workstudy , int const stafford, double pellgrant) // function for adding up workstudy loan, stafford loan, and pellgrant loan
{
double Total;

Total = workstudy + stafford + pellgrant;

return (Total); // returns total
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com