Write a function numberofpennies() that returns the total number of pennies given a number of dollars and (optionally) a number of pennies. ex: 5 dollars and 6 pennies returns 506.

Question
Answer:
What language are you writing this in? C? Javascript? Java? Are you allow to have parameters? 
The general idea should be the same. Since 1 dollar  = 100 pennies, we should write something like...

Java:
public static double numberofpennies(double dollars, double penny) {         
           double sum = 0;                  

           // The amount of pennies that dollar represents       
           double converted = dollars * 100.0;                  

           sum = converted + penny;
         
           return sum;   
}
Note: You should probably place this question under the category computer and technology instead of math. Also, this is just an example of what you could possibly write. What parameters you are allowed to use, what type (double? int? etc?) of pennies are you allowed to return, etc. depends on how you write it. 



solved
general 11 months ago 8153