Question: I have the code almost right, I just need it to round to only 2 decimals places & am not sure how to do that

I have the code almost right, I just need it to round to only 2 decimals places & am not sure how to do that in C.I have the code almost right, I just need it to roundto only 2 decimals places & am not sure how to do

DESCRIPTION A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is $0.38, and the profit of each carton of milk is $0.27. Write a program that: 1. Prompts the user to enter the total amount of milk produced in liters. 2. Outputs the number of milk cartons needed to hold milk. 3. Outputs the cost of producing the milk. 4. Outputs the profit from producing the milk. For example (sample user inputs are shown with an underline): Enter, in liters, the total quantity of milk produced: 3.78 The number of milk cartons needed to hold milk: 1 The cost of producing milk: $ 1.44 Profit: $ 0.27 nunc C2.2.c:16:16: warning: incompatible implicit declaration of built-in func tion 'ceil' C2.2.c:16:16: note: include '' or provide a declaration of 'ceil' C2.2.c:7:1: #include 12 6 #include 7 #include 8 9 int main() 10- { 11 double liters; int numCartons; 13 14 printf("Enter, in liters, the total quantity of milk produced: "); scanf("%lf",&liters); 16 17 numCartons=(liters/3.78); 18 19 printf("The number of milk cartons needed to hold milk: %d " , numCartons); C2.2.c:16:16: numCartons ceil(liters/3.78); 15 20 printf("The cost of producing milk: $ %21f ", liters*0.38); printf("Profit: $ %21f ", numCartons*0.27); 21 22 23 24 25 26 27 } return 0; \/tmp/ccZdKhAd.o: In function 'main': C2.2.c:(.text+0x52): undefined reference to ceil' Icollect2: error: ld returned 1 exit status user@mimir: ~/cpsc_1010_all_sections_spring2021/chapterproject_22 > gcc -Wall C2.2.0 \/tmp/ccmLX9Jo.0: In function 'main': C2.2.c:(.text+0x52): undefined reference to ceil' Icollect2: error: ld returned 1 exit status user@mimir: ~/cpsc_1010_all_sections_spring2021/chapterproject_22 > gcc Wall C2.2.c user@mimir: ~/cpsc_1010 all_sections_spring2021/chapterproject_22 > ./a. out Enter, in liters, the total quantity of milk produced: 3.78 The number of milk cartons needed to hold milk: 1 The cost of producing milk: $1.436400 Profit: $0.270000 user@mimir: ~/cpsc_1010_all_sections_spring2021/chapterproject_22 > gcc Wall C2.2.c user@mimir: ~/cpsc_1010 all_sections_spring2021/chapterproject_22 > ./a. out Enter, in liters, the total quantity of milk produced: 5 The number of milk cartons needed to hold milk: 1 The cost of producing milk: $1.900000 Profit: $0.270000 fuser@mimir: ~/cpsc_1010_all_sections_spring2021/chapterproject_22 >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!