Here\'s the assignment: If we only had pennies and not all the other coins and v
ID: 3666314 • Letter: H
Question
Here's the assignment:
If we only had pennies and not all the other coins and various bills … How many pennies is that? How much do they weigh? How much space do they take? Your program will read eight numbers from the user. These eight inputs correspond to the number of $20 bills, $10 bills, $5 bills, $1 bills, quarters, dimes, nickels and pennies that you have. Each of these inputs is an integer value. The user will always enter them in this order ($20–$10–$5–$1–quarter–dime–nickel–penny) and will always give legal input values (all the inputs will be zero or a positive integer). To complete this project, you need to know a couple of basic facts about pennies. First, we assume all the pennies are new (copper plated zinc) pennies. These pennies Have a weight of 2.500 grams Have a diameter of 0.750 inches Have a thickness of 1.52mm (recall that there are 25.4 mm in one inch). For this project, you need to use functions.At a minimum, you need: A function to get input from the user. This function takes one argument (a character string that is the prompt for the user when entering input), prints the prompt, reads a single integer from standard input, and returns the integer value that was entered. A function that takes an integer representing the total number of pennies that you have and computes the weight of those pennies in pounds. It returns a double that represents this weight. A function that takes an integer representing the total number of pennies that you have and computes the volume of these pennies in cubic feet. It returns a double that represents this volume. In pennies.c, write the code needed to solve the problem stated above. Make sure that your program o Has a header block of comments that includes your name and a brief overview of the program o Reads eight values from the user (twenties, tens, fives, ones, quarters, dimes, nickels, pennies) o Use at least three functions – one for input, one to calculate weight, one to calculate volume o Prints the three expected outputs The equivalent total number of pennies for this amount of money The total weight of these pennies (in pounds) The total volume of these pennies (in cubic feet)
Pretty confused especially about the functions, any help would be much appreciated!
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
int twentyDolllar,tenDollar,fiveDollar,oneDollar,quarter,dime,nickel,penny;
int totalpenny;
float tpennyWeight,pennyWeightGMS;
double weightPounds,totalVpennyCC,totalVolumePenny,volumeOnePenny;
void input(char str[])
{
printf("%s",str);
printf("Enter the bill value of twenty dollar");
scanf("%d",twentyDollar);
printf("Enter the bill value of ten dollar");
scanf("%d",tenDollar);
printf("Enter the bill value of five dollar");
scanf("%d",fiveDollar);
printf("Enter the bill value of one dollar");
scanf("%d",oneDollar);
printf("Enter the value of quater");
scanf("%d",quarter);
printf("Enter the value of dime");
scanf("%d",dime);
printf("Enter the value of nickle");
scanf("%d",nickle);
printf("Enter the value of penny");
scanf("%d",penny);
totalpenny=twentyDollar*100+tenDollar*100+fiveDollar*100+oneDollar*100+quater*25+dime*10+nickle*5+penny;
}
void pennyWeight()
{
printf("Enter the total number of pennies");
scanf("%d",totalpenny);
pennyWeightGMS=totalpenny*2.500;
weightPounds=pennyWeightGMS/453.6;
return weightPounds;
}
void pennyvolume()
{
printf("Enter the total number of pennies");
scanf("%d",totalpenny);
volumeOnePenny=3.14*9.525*9.525*1.52;
totalVolumePenny=totalpenny*volumeOnePenny;
totalVpennyCC=totalVolumePenny/1000;
return totalVpennycc;
}
void main()
{
input("Hello user");
pennyWeight();
pennyVolume();
getch()
}