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

Modify cents.c (down) that asks the user to enter a number for cents and then ca

ID: 3666115 • Letter: M

Question

Modify cents.c (down) that asks the user to enter a number for cents and then calculatesthe number of quarters, dimes, nickels, and pennies needed to add up to that amount

So it includes the following function:
void coins(int cents, int *quarters, int *dimes, int *nickels,int *pennies);

The function determines the smallest number of quarters, dimes, nickels, and penniesnecessary to add up to the amount of cents represented by the cents parameter. Thequarters parameter points to a variable in which the function will store the number of$20 bills required. The dimes, nickels, and pennies parameters are similar. Modifythe main function so it calls coins  to compute the number of quarters, dimes, nickels,and pennies. The main function should contain the printf statements that display theresult.

#include <stdio.h>
#define QUARTER 25
#define DIME 10
#define NICKEL 5
#define PENNY 1

int main()
{
   //initialize variables and read input
   int cents, pennies, quarters, dimes, nickels;
   pennies = quarters = dimes = nickels =0;
printf("Enter the number of cents: ");
   scanf("%d", &cents);

   //check the range of the input amount
   if(cents< 0 || cents > 10000)
   printf("Invalid amount %d, Amount must be between 0 and 10000, inclusive ", cents);
else {
       quarters = cents/QUARTER;
       dimes = cents%QUARTER/DIME;
       nickels = cents%QUARTER%DIME/NICKEL;
       pennies = cents%QUARTER%DIME%NICKEL;

       printf("Quarters: %d ", quarters);
   printf("Dimes: %d ", dimes);
   printf("Nickels: %d ", nickels);
   printf("Pennies: %d ", pennies);
   }
   return 0;
}

  

Explanation / Answer

class Program { //Allowable denominations const int penny = 1; const int nickel = 5; const int dime = 10; const int quarter = 25; const int maxCurrencyLevelForTest =55; //1-n where n
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