Input error help
Feb 1, 2018 at 11:13pm UTC
I am having trouble running my program. My computer said the error has to do with my input. I would appreciate any help. The program is supposed to print the amt. of ingredients needed for any batch of cookies. The batch of cookies being the input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
//
// Grant
// CMPSC 121
// 1/31/2018
// Description
//
// Pound includes
#include<iostream>
using namespace std;
// Class Definitions
class Recipe {
public :
// Constant amounts for 96 cookies
const double sugar = 2.5;
const double butter = 1.5;
const double flour = 3.5;
const int cookies = 96;
// Multiplier
double cookiesToMake;
double cookieMultiplier;
// Recipe Amounts
double recipeSugar;
double recipeButter;
double recipeFlour;
int recipeCookies;
};
int main(void ) {
// Splash Screen
cout << endl;
cout << "Grant Wynn" << endl;
cout << "CMPSC 121" << endl;
cout << "January 31 2018" << endl;
cout << "Program Description" << endl;
cout << endl;
// Create the Recipe Object
Recipe myCookies;
// Initialize all of the recipe amounts and enter cookies to make
myCookies.recipeSugar;
myCookies.recipeButter;
myCookies.recipeFlour;
myCookies.recipeCookies = 96;
cout << "How many cookies do you want to make?" << endl;
cin >> myCookies.cookiesToMake >> endl;
// Calculate the multiplier
myCookies.cookieMultiplier = myCookies.cookiesToMake / myCookies.cookies;
// Calculate the recipe amounts
myCookies.recipeSugar = myCookies.sugar * myCookies.cookieMultiplier;
myCookies.recipeButter = myCookies.butter * myCookies.cookieMultiplier;
myCookies.recipeFlour = myCookies.flour * myCookies.cookieMultiplier;
// Print the results
cout << myCookies.cookiesToMake << "cookies" << endl;
cout << myCookies.recipeSugar << "cups of sugar" << endl;
cout << myCookies.recipeButter << "cups of butter" << endl;
cout << myCookies.recipeFlour << "cups of flour" << endl;
// Including number of cookies to make and the amount of each ingredient
return 0;
};
Feb 2, 2018 at 12:57am UTC
Line 53 should be:
cin >> myCookies.cookiesToMake;
and not:
cin >> myCookies.cookiesToMake >> endl;
Topic archived. No new replies allowed.