Okay, I'm going to preface this by saying I don't take this forum for granted, and the help I've received from this forum (simply by reading previous threads).
I'm taking my 1st CS class and I'm stuck on this current assignment. If anybody could guide me in the right direction, that would be amazing.
Directions (copy and pasted from teacher document):
I am planning on becoming a viticulturist (wine maker). I need to know how many bottles of wine I can expect from my grape vines per year, given the size of my grape fields in acres. I also need to know the wine yield in gallons per year.
Assume a ton of grapes makes about 152.5 gallons of wine. About 2.377 gallons of wine are required to fill a case of twelve 750ml bottles.
An established vineyard can produce about 6.2 tons of grapes per acre per year.
Sample Dialog
Welcome to John Doe’s Viticulture Program.
How many acres of grape vines are you growing?
Acres: 9.5
The number of bottles of wine you can expect is: 45345
This is equivalent to 8982.25 gallons.
Thank you for using John Doe’s Viticulture Program.
This is what I have so far. I'm so close to understanding it, but I feel like I'm missing some command or something.
#include <iostream>
using namespace std;
void main()
{
double x;
double y;
double z;
cout << "Welcome to John Doe's viticulture program!" << endl;
cout << "How many acres of grape vines are you growing?" << endl;
cout << "Acres: ";
cin >> x;
cin >> y;
cout << "The number of bottles of wine you can expect is: ";
cout << x * 6.2 = y >> y * 152.5 = z;
system("pause");
}
Basically, what I'm trying to do is tell the program to do this;
x = the users input for how many acres they are growing on.
Then I tell the computer to do
x(6.2)= y
y(152.5)=z
Z = gallons of wine.
I'm struggling with when to use cin >>
I feel like I'm close to finishing this, but I'm not sure how to tell the program to keep doing more and more steps of arithmetic.
As stated, any help would be vastly appreciated. Thank you.
#include <iostream>
usingnamespace std;
void main()int main()
{
double x;
double y;
double z;
cout << "Welcome to John Doe's viticulture program!" << endl;
cout << "How many acres of grape vines are you growing?" << endl;
cout << "Acres: ";
cin >> x;
cin >> y;
cout << "The number of bottles of wine you can expect is: ";
y = x * 6.2;
z = y * 152.5;
cout << "Z: " << z << endl;
cout << "Y: " << y << endl;cout << x * 6.2 = y >> y * 152.5 = z;
system("pause");
return 0;
}
I've been chewing on this for the last few hours and this is what I have
double x;
double y;
double z;
cout << "Welcome to John Doe's viticulture program!" << endl;
cout << "How many acres of grape vines are you growing?" << endl;
cout << "Acres: ";
cin >> x;
cout << "The number of bottles of wine you can expect is: ";
cout << x * 6.2 * 152.5 / 2.377 * 12 << endl;
cout << "This is equivalent to: ";
cout << x * 6.2 * 152.5;
cout << " gallons" << endl;
cout << "Thank you for using John Doe's Viticulture Program." << endl;
system("pause");
Is the above work correct? This is my 'finished' product to the best of my abilities, and the program does what I say.
I've left out the #include <oistream stuff, etc. Just giving you guys the guts.
My question is this: My finished product shows a decimal, and the assignment says I can't have decimals. How do I make it so I can't get decimals?
Our teacher told us "cout >> precision(2);" as a tip, but I tried "cout >> precision(0)" but I couldn't figure anything out.
Any help would be appreciated. Also, TheJJJunk, I haven't compiled your finished product yet, and our programs are very different. Is one superior compared to the other?
Thanks for taking the time to help guys, honestly!