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

Write a program that takes cents as an integer and converts it to dollars and ce

ID: 3551263 • Letter: W

Question

  • Write a program that takes cents as an integer and converts it to dollars and cents.
  • The conversion should be done in a function called NormalizeMoney. This function is given a value in cents. It will convert cents to dollars and cents, which should be stored in a local variable called dollars which is returned to the calling function. NormalizeMoney will keep a running total of all the money processed in a local static variable called sum. Each time NormalizeMoney is called it should print out the sum before returning.
  • Main function should prompt the user for cents and keep prompting till the user is done. For each cent value received, main function should print out the dollar equivalent.

Explanation / Answer

#include<iostream>
using namespace std;
static int sum=0;
int NormalizeMoney(int );
int main()
{
    char ch;
do
{
        int cent,c;
        cout<<"Enter Cents : "<<endl;
        cin>>cent;
        int doller;
        doller=NormalizeMoney(cent);
        c=cent%100;
        cout<<endl<<cent<<" Cents = "<<doller<<" Doller and "<<c<<" Cent"<<endl;
        cout<<"Wants to do more conversion : Y/N    :";
        cin>>ch;
}while(ch!='n'||ch!='N');

return 0;
}
int NormalizeMoney(int cent)
{
    int doller;
    doller=cent/100;
    sum=sum+cent;
    cout<<endl<<"Sum = "<<sum<<"Cents";
return doller;
}

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