i wrote this program it c++ in response to this question "total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk (which will need to be a value rounded up to the nearest integer), the cost of producing the milk and the profit from producing this milk." but i keep getting these errors in my program.

#include <iostream>
#include <cmath>
using namespace std;

int main ()

double LitersMilkProduce;

double cartons, totalcost, totalprofit;

 const double LITERCOST(0.38), CARTONPROFIT(0.27), LITERS_PER_CARTONS= (3.78);

cout << "Enter the total number of liters: ";
cin >> LitersMilkProduce;

cartons = LitersMilkProduce / LITERS_PER_CARTONS;
totalcost = LitersMilkProduce * LITERCOST;
totalprofit = static_cast (cartons) * CARTONPROFIT;

cout << "The total number of liters = " << LitersMilkProduce << endl;

cout << fixed << showpoint<< setprecision(2) <<fixed <<  "Amount of cartons = " << cartons <<endl;
cout << "\nEnd of Program\n\n";
return 0;
4 Years
Discussion Span
Last Post by Bob

but i keep getting these errors in my program.

What errors? I don't see any errors posted at all.


when i build program errors c2059 0n line 24
and error c3861 line 29 saying their is no indicator for setprecision


I'm not a compiler. I have no idea what c2059 and c3861 means. Copy and paste the exact error message, and make sure the line numbers match your code.


Hi chris.vargas.773,

#include <iomanip> // for setprecision

Your syntax for static_cast is incorrect, s/b static_cast<type>(expression)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.