Question

In: Computer Science

I'm having trouble with this program here's the problem: A milk carton can hold 3.78 liters...

I'm having trouble with this program

here's the problem:

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 does the following:

  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. (Round your answer to the nearest integer.)
  3. Outputs the cost of producing the milk.
  4. Outputs the profit from producing the milk.

Here's the program:

#include <stdio.h>

int main(void){

const float cartoncapacity=3.78;

const float costperliter=0.38;

float profitpercarton=0.27;

float milkproduced, milkcost;

int cartonsneeded;

double profit;

printf("Enter, liters, the total quantity of milk produced:\n");

scanf("%f", &milkproduced);

cartonsneeded=((milkproduced+3.78)/cartoncapacity);

printf("Total number of cartons needed to hold:\n");

scanf("%d",&cartonsneeded);

milkcost=costperliter*milkproduced;

profit=profitpercarton*cartonsneeded;

  

printf("The cost of producing milk $ %f", &milkcost);

  

  

printf("Profit: $ %lf",&profit);

  

  

  

  

return (0);

}

Solutions

Expert Solution

#include <stdio.h>

int main(void){
   const float cartoncapacity=3.78;
   const float costperliter=0.38;
   float profitpercarton=0.27;
   float milkproduced, milkcost;
   int cartonsneeded;
   double profit;
   
   printf("Enter, liters, the total quantity of milk produced:
");
   scanf("%f", &milkproduced);

   printf("Total number of cartons needed to hold:
");
   scanf("%d",&cartonsneeded);
   
   milkcost=costperliter*milkproduced;
   profit=profitpercarton*cartonsneeded;
   
   printf("The cost of producing milk $ %f
", milkcost);
   printf("Profit: $ %lf",profit);
   return (0);
}


Related Solutions

C++ please A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm...
C++ please 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 prompts the user to enter: The total amount of milk produced in the morning. The program then outputs: The number of milk cartons needed to hold milk. Round your answer to...
I'm having trouble trying to create the italian, polish, and netherlands flag in C Here's my...
I'm having trouble trying to create the italian, polish, and netherlands flag in C Here's my code so far: #include<stdio.h> int main(){    int country_choice;    fprintf(stderr, "Enter the country_code of the chosen flag.(1 for Poland, 2 for Netherlands, 3 for Italy)");    fscanf(stdin, "%d", &country_choice);    switch (country_choice) { case 1: printf("Poland Flag\n"); printf("%c%c%c", 255,255,255); printf("%c%c%c", 220,20,60);    break;       case 2: printf("Italian Flag\n"); printf("%c%c%c", 0,146,70); printf("%c%c%c", 225,255,255); printf("%c%c%c", 206,43,55); break;    case 3: printf("Netherlands Flag\n"); printf("%c%c%c", 174,28,40);...
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing...
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing 55x + 45y, however the variables are throwing me off. I only need help on question #1 as it would be a great help to understanding the rest of what the questions are asking. The problem is as follows: NorCal Outfitters manufactures a variety of specialty gear for outdoor enthusiasts. NorCal has decided to begin production on two new models of crampons: the Denali...
I'm having trouble figuring out what the standard deviation is for the following problem. Common stock...
I'm having trouble figuring out what the standard deviation is for the following problem. Common stock of Escapist Films sells for $30 a share and offers the following payoffs next year: Boom 0 $21 Normal $1 $32 Recession $3 $36 The expected return of Escapist is: Boom -30% Normal 10% Recession 30% Calculate the standard deviation of Escapist.
C# Arrays & methods I'm having trouble implementing the GetIntArrayFromUser method in the following problem: Create...
C# Arrays & methods I'm having trouble implementing the GetIntArrayFromUser method in the following problem: Create a method AverageIntArray that takes an array of integers and calculates and returns the average of all values in the array as a double Write a program that uses GetIntArrayFromUser method to get an array of 7 numbers, then calls the AverageIntArray method to get the average then prints all values in the array that are greater than the average.                 Sample run:                                ...
I'm having trouble with my do while loop. I'm trying to get it where if the...
I'm having trouble with my do while loop. I'm trying to get it where if the user enter's 3 after whatever amount of caffeinated beverages they've entered before then the loop will close and the rest of my code would proceed to execute and calculate the average price of all the caffeinated beverages entered. Can someone please help me with this? Here's my Code: import java.util.Scanner; public class Main { public static void main(String[] args) { CaffeinatedBeverage[] inventory = new...
I'm having trouble thinking of a way that I can delete duplicates from a c string...
I'm having trouble thinking of a way that I can delete duplicates from a c string of alphabets. So what I'm supposed to do is I'm supposed to delete the repeated letters in the c string using pointers and also dynamically allocating space. I'm guessing that I will have to dynamically allocate space for an array to put in the letters that only appear once. To do that, can I create 2 pointers in a function and have 1 pointer...
I'm trying to explain in simple terms what the weak interaction does, but I'm having trouble...
I'm trying to explain in simple terms what the weak interaction does, but I'm having trouble since it doesn't resemble other forces he's familiar with and I haven't been able to come up (or find on the web) with a good, simple visualization for it.
I'm having trouble creating a histogram using openCV (color segmentation)
I'm having trouble creating a histogram using openCV (color segmentation)
I am having trouble with a C++ code that I'm working on. It is a spell...
I am having trouble with a C++ code that I'm working on. It is a spell checker program. It needs to compare two arrays, a dictionary, and an array with misspelled strings that are compared to the strings in the dictionary. the strings that are in the second array that is not in the Dictionary are assumed to be misspelled. All of the strings in the dictionary are lowercase without any extra characters so the strings that are passed into...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT