I have a project due that I don\'t understand how to write. I\'m new to programm
ID: 641630 • Letter: I
Question
I have a project due that I don't understand how to write. I'm new to programming and my online teacher is no help. Heres the questions I don't understand how do I proram this using VC++.
LAB 5 PASS BY VALUE FUNCTIONS
1 Reversing Digits - Complete the template program reverseNumber.cpp
2 Compute Tax: Write a function that has a double as a parameter and returns a double through the function call. The parameter is the income for a single person and the return value is the amount of income tax owed. Use the Schedule X
Explanation / Answer
#include <iostream>
using namespace std;
// Function declaration / prototype
/*** STUDENT YOUR PROTOTYPE HERE ***/
int reverseDigits(int n);
int main()
{
int number; // input number
cout << "Enter a number: ";
cin >> number;
cout << "The number with its digits reversed is: ";
// display number with digits reversed
/******* STUDENT WRITES CODE HERE **********
call the function whigh reverses the digits
and display the result
******************************************/
cout << reverseDigits(number) << endl;
return 0; // indicate successful termination
} // end main
int reverseDigits(int n)
// reverseDigits returns number obtained by reversing digits of n
// Write function header for reverseDigits */
/***** STUDENT WRITES CODE BELOW ***************/
{
int reverse = 0; // reversed number
while (n > 0)
{
reverse *= 10; // shift the digits of reverse to the left
reverse += n % 10; // add the ones-digit of n to reverse
n /= 10; // shift the digits of n to the right
}
return reverse;
// return the value of the variable reverse
} // end function reverseDigits
__________________________________________________________________________________
double computeTax(double income){
if(income > 0 && income <= 7550){
return income * 0.1;
}
else if(income > 7550 && income <= 30650){
return (755) + ((income - 7550) * 0.15);
}
else if(income > 30650 && income <= 74200){
return (4220) + ((income - 30650) * 0.25);
}
else if(income > 74200 && income <= 154800){
return (15107.5) + ((income - 74200) * 0.28);
}
else if(income > 154800 && income <= 336550){
return (37675.5) + ((income - 154800) * 0.33);
}
else if(income > 336550){
return (97653.5) + ((income - 336550) * 0.35);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.