Due: Monday, September 8th by 11:59 PM
This assignment is a warm-up exercise. Future assignments will be more difficult!
Write a program that solicits numbers of pennies, nickels, dimes, and quarters from the user and computes the total value of each denomination in cents and total monetary amount in both cents and dollars.
An example run of the program should look something like this.
You should store the number of each kind of coin (pennies, nickels, etc.) in a different variable. Use int as the type of each variable.
For example, if you are using a variable called num_pennies to store the number of pennies, you can prompt the user for the number of pennies as follows:
printf("Enter the number of pennies: "); scanf("%i", &num_pennies);
Note: When using the scanf function to read values into numeric variables, remember to include the & (ampersand) in front of each variable!
In C, addition and multiplication are performed using the + and * operators. A chunk of C code that computes a value is called an expression. The + and * operators allow you to construct expressions that perform addition and multiplication, respectively.
For example, if the variable num_quarters contains the number of quarters entered by the user, the C expression
quarter_total = num_quarters * 25;
computes an integer value for the total number of cents for the quarters and stores it in a variable called quarter_total.
Once you have computed an integer value, you can print it using the printf function. For example, the C statement
printf("Amount from quarters: %i cents.\n", quarter_total);
prints the value of the quarters. The %i character is a placeholder which is replaced by the value of the variable quarter_total when the message is printed. The \n is a special character that represents a new line, i.e. subsequent output will begin on the next line.
Run the program and type in several combinations of coins. Make sure the program produces the correct output, including proper formatting of the dollar field.