Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am to write a code that asks the user for the amount of a currency called Flor

ID: 3638320 • Letter: I

Question

I am to write a code that asks the user for the amount of a currency called Floridens, sends the amount to a function to determine the tax rate and tax amount due, then output the tax rate and tax amount. My code is working fine in the gedit compiler and does what it is supposed to do except for one issue: the tax rate is not being correctly outputted. This is my code:

#include <iostream>
#include <iomanip>
using namespace std;

double taxes(double &flor)
{
double ratedue, amountdue;
int r;
int rate[] = {0, 5, 7, 12, 19, 23, 31, 37, 43, 66};
if (flor <= 1)
{ratedue = rate[0];
amountdue = flor*ratedue;}
else if (flor > 1 & flor <= 9)
{r = flor -1;
ratedue = rate[r];
ratedue = ratedue*.01;
amountdue = flor *ratedue;}
else
{ratedue = rate[9];
ratedue = ratedue * .01;
amountdue = flor*ratedue;}

return ratedue, amountdue;
}

int main()
{
double floriden, tax, pay;
cout << "Enter Floriden amount: ";
cin >> floriden;
tax, pay = taxes(floriden);
cout << fixed;
cout << "Tax rate: " << setprecision(2) << tax << endl;
cout << "Amount due: " << setprecision(2) << pay << endl;
return 0;
}

This is my output:

Enter Floriden amount: 7
Tax rate: 0.00
Amount due: 2.17

Notice the tax rate displays 0.00. This occurs no matter what number is inputted by the user. Please help ASAP!!

Explanation / Answer

A function can not return two objects in c++. >> (return ratedue, amountdue);
Please choose an alternative way...

You may take an extra variable through call by reference and change its value inside the function itself.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote