37.7k views
5 votes
Given int variables called dollars, quarters, dimes, nickels and pennies, write an expression that computes the total amount of the money represented in the variables. The result should be an integer value representing the number of pennies in the total.

1 Answer

4 votes

Final answer:

To compute the total amount of money represented in the variables, convert each variable into pennies and then add them up. The expression to compute the total amount in pennies would be (dollars * 100) + (quarters * 25) + (dimes * 10) + (nickels * 5) + pennies.

Step-by-step explanation:

To compute the total amount of money represented in the variables, we need to convert each variable into pennies and then add them up. In this case, we can consider:

  • 1 dollar = 100 pennies
  • 1 quarter = 25 pennies
  • 1 dime = 10 pennies
  • 1 nickel = 5 pennies

So the expression to compute the total amount in pennies would be: (dollars * 100) + (quarters * 25) + (dimes * 10) + (nickels * 5) + pennies.

User MorningGlory
by
8.2k points