#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Problem with a function


    I'm working on a project that needs to call a function. But I can't get it to work. This is my first time trying to write programs. Very new and novice. Not sure how to post my code, because it is over 200 lines. Need some help with that first???????
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    here is code


    #include<iostream>
    #include<iomanip>
    #include <string>
    using namespace std;

    void getBiscuits(string & mBiscuitChoice, double & mNumberOfBoxes, double & mBiscuitPrice);

    void getDryFood(string & mDryFoodChoice, double & mNumberOfBags, double & mDryFoodPrice);

    void showProcessData(double mMyOrderPrice, double mBiscuitPrice, double mDryFoodPrice, double mNumberOfBoxes, double mNumberOfBags, double & mSubTotal, double & mSalesTax, double & mTotal);

    void showDisplayOrder(string mBiscuitChoice, double mNumberOfBags, string mDryFoodChoice, double mNumberOfBoxes, double mSubTotal, double mSalesTax, double mTotal, string mName);

    double makeYourOwn(double myOrderPrice);

    int main(){

    string name;
    string biscuitChoice;
    string dryFoodChoice;

    char orderToday;
    char makeOwnBiscuits;
    char biscuitOrder;
    char dryFoodOrder;
    double makeYourOwn;
    double myOrderPrice = 0;
    double numberOfBoxes = 0;
    double numberOfBags = 0;
    double biscuitPrice = 0;
    double dryFoodPrice = 0;
    double biscuitCost = 0;
    double dryFoodCost = 0;
    double subTotal = 0;
    double salesTax = 0;
    double total = 0;

    cout << "Welcome to Buster's Best Biscuits and Gourmet Dog Food." << endl;

    //Priming Read
    cout << "Would you like to place an order with us today Y/N" << endl;
    cin >> orderToday;
    if(toupper(orderToday) == 'Y');


    //While Loop

    while (orderToday == 'y'){

    //Reinitialize Variables
    double subTotal = 0;
    double salesTax = 0;
    double total = 0;

    cin.ignore();
    cout << "Please tell me your first name?" << endl;
    getline(cin, name);


    //Make your own Biscuits Function
    cout << name << " Would you like to make your own biscuits today? Y/N" << endl;
    cin >> makeOwnBiscuits;
    if (toupper(makeOwnBiscuits) == 'Y')

    //Call Function Make your own biscuits
    double makeYourOwn(double myOrderPrice);



    cout << name << " Would you like to order some Pre-Made biscuits today? Y/N" << endl;
    cin >> biscuitOrder;
    if (toupper(biscuitOrder) == 'Y')

    getBiscuits(biscuitChoice, numberOfBoxes, biscuitPrice);

    cout << name << " Would you like to order any Dry Dog Food today? Y/N" << endl;
    cin >> dryFoodOrder;
    if (toupper(dryFoodOrder) == 'Y')

    getDryFood(dryFoodChoice, numberOfBags, dryFoodPrice);

    showProcessData(myOrderPrice, biscuitPrice, dryFoodPrice, numberOfBoxes, numberOfBags, subTotal, salesTax, total);

    showDisplayOrder(biscuitChoice, numberOfBoxes, dryFoodChoice, numberOfBags, subTotal, salesTax, total, name);

    //Check to see if customer wants to order again
    cout << name << " Would you like to place another order with us today? Y/N" << endl;
    cin >> orderToday;

    }

    system("pause");
    return 0;
    }

    void getBiscuits(string & mBiscuitChoice, double & mNumberOfBoxes, double & mBiscuitPrice){
    system("cls");
    int selection = 0;

    do{
    system("cls");

    cout << "1. Tiny Dog- under 5lbs, Tiny Biscuit - 5.00 " << endl;
    cout << "2. Small Dog- 5lbs to 8lbs, Small Biscuit - 6.00" << endl;
    cout << "3. Medium Dog- 8lbs to 20lbs, Medium Biscuit- 7.00" << endl;
    cout << "4. BIG DOG - 20lbs to 50lbs, Big Biscuit- 8.00" << endl;
    cout << "5. HUGE DOG - 50lbs and up, HUGE Biscuit-9.00" << endl;

    cout << "Please select a number from the menu above." << endl;
    cin >> selection;

    if (selection < 1 || selection >5){
    cout << "Please select 1 through 5 ONLY" << endl;
    system("pause");
    }
    } while (selection < 1 || selection >5);

    cout << "How many boxes of Biscuits would you like to order? \n " << endl;
    cin >> mNumberOfBoxes;

    switch (selection){
    case 1:
    mBiscuitChoice = "Tiny Dog- under 5lbs, Tiny Biscuit";
    mBiscuitPrice = 5.00;
    break;

    case 2:
    mBiscuitChoice = "Small Dog- 5lbs to 8lbs, Small Biscuit";
    mBiscuitPrice = 6.00;
    break;

    case 3:
    mBiscuitChoice = "Meduim Dog- 8lbs to 20lbs, Meduim Biscuit";
    mBiscuitPrice = 7.00;
    break;

    case 4:
    mBiscuitChoice = "BIG DOG - 20lbs to 50lbs, Big Biscuit";
    mBiscuitPrice = 8.00;
    break;

    case 5:
    mBiscuitChoice = "HUGE DOG - 50lbs and up, HUGE Biscuit";
    mBiscuitPrice = 9.00;
    break;

    default:
    cout << "Selection must be from 1 to 5 - selection changed to zero." << endl;
    }
    }


    void getDryFood(string & mDryFoodChoice, double & mNumberOfBags, double & mDryFoodPrice){
    system("cls");
    int selection = 0;

    do{
    system("cls");


    cout << "1. Tiny Dog- under 5lbs, Tiny Food - 10.00 " << endl;
    cout << "2. Small Dog- 5lbs to 8lbs, Small Food - 12.00" << endl;
    cout << "3. Medium Dog- 8lbs to 20lbs, Medium Food- 14.00" << endl;
    cout << "4. BIG DOG - 20lbs to 50lbs, Big Food- 18.00" << endl;
    cout << "5. HUGE DOG - 50lbs and up, HUGE FOOD-20.00" << endl;

    cout << "Please select a number from the menu above." << endl;
    cin >> selection;

    if (selection < 1 || selection >5){
    cout << "Please select 1 through 5 ONLY" << endl;
    system("pause");
    }
    } while (selection < 1 || selection > 5);

    cout << "How many bags of food would you like to order? \n " << endl;
    cin >> mNumberOfBags;

    switch (selection){
    case 1:
    mDryFoodChoice = "Tiny Dog- under 5lbs, Tiny Food";
    mDryFoodPrice = 10.00;
    break;

    case 2:
    mDryFoodChoice = "Small Dog- 5lbs to 8lbs, Small Food";
    mDryFoodPrice = 12.00;
    break;

    case 3:
    mDryFoodChoice = "Meduim Dog- 8lbs to 20lbs, Meduim Food";
    mDryFoodPrice = 14.00;
    break;

    case 4:
    mDryFoodChoice = "BIG DOG - 20lbs to 50lbs, Big Food";
    mDryFoodPrice = 18.00;
    break;

    case 5:
    mDryFoodChoice = "HUGE DOG - 50lbs and up, HUGE FOOD";
    mDryFoodPrice = 20.00;
    break;

    default:
    cout << "Selection must be from 1 to 5 - selection changed to zero." << endl;
    }
    }

    void showProcessData(double mMyOrderPrice, double mBiscuitPrice, double mDryFoodPrice, double mNumberOfBoxes, double mNumberOfBags, double & mSubTotal, double & mSalesTax, double & mTotal){ double mBiscuitCost = mBiscuitPrice * mNumberOfBoxes; double mDryFoodCost = mDryFoodPrice * mNumberOfBags;


    mBiscuitCost = mBiscuitPrice * mNumberOfBoxes;
    mDryFoodCost = mDryFoodPrice * mNumberOfBags;
    mSubTotal = mMyOrderPrice + mBiscuitCost + mDryFoodCost;
    mSalesTax = mSubTotal * .07;
    mTotal = mSubTotal + mSalesTax;
    }

    void showDisplayOrder(string mBiscuitChoice, double mNumberOfBags, string mDryFoodChoice, double mNumberOfBoxes, double mSubTotal, double mSalesTax, double mTotal, string mName){

    cout << setprecision(2) << fixed;

    cout << "Thank you " << mName << " For your order." << endl;
    cout << "You ordered " << mNumberOfBags << " of the " << mBiscuitChoice << "and " << mNumberOfBoxes <<" of the " << mDryFoodChoice << endl;

    cout << "Your subtotal today is $" << mSubTotal << endl;
    cout << "Your sales tax today is $" << mSalesTax << endl;
    cout << "Your Grand Total today is $" << mTotal << endl;
    }

    //Function Make your own biscuits
    double makeYourOwn(double myOrderPrice){

    int selection = 0;
    double price = 0;

    cout << "Would you like to use Brown Rice? - Price $10.00 for 20 biscuits y/n"<< endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 10.00;

    cout << "would you liek to use Brown Rice and Salmon? - Price $12.00 for 20 Biscuits y / n" <<endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 12.00;

    cout << "Would you like to use Brown Rice and lamb? - Price $14.00 for 20 Biscuits y / n" <<endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 14.00;

    cout << "Would you like to use Brown Rice, Salmon, and lamb? - Price $16.00 for 20 Biscuits y / n" <<endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 16.00;

    cout << "would you like to use Green Eggs and Ham? - Price $18.00 for 20 Biscuits y / n" <<endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 18.00;

    cout << "would you like to use Steak and Lobster? - Price $20.00 for 20 Biscuits y / n" <<endl;
    cin >> selection;
    if (toupper(selection) == 'Y');
    price += 20.00;

    return price;
    }
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    Yes, a 200 line program is sorely in need of some functions.
    read this guide

    Part of it being, "don't dig such a deep hole before deciding to do something about it".

    As for posting code, it goes something like this.

    This is what you write in the web browser edit window
    [code]
    int main ( ) {
    return 0;
    }
    [/code]


    Should end up looking like this.
    Code:
    int main ( ) {
        return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,253
    Rep Power
    2222
    With code tags, your code looks like this -- original format retrieved via the Reply button:
    Code:
    #include<iostream> 
    #include<iomanip> 
    #include <string> 
    using namespace std; 
     
    	void getBiscuits(string & mBiscuitChoice, double & mNumberOfBoxes, double & mBiscuitPrice); 
     
    	void getDryFood(string & mDryFoodChoice, double & mNumberOfBags, double & mDryFoodPrice); 
    	 
    	void showProcessData(double mMyOrderPrice, double mBiscuitPrice, double mDryFoodPrice, double mNumberOfBoxes, double mNumberOfBags, double & mSubTotal, double & mSalesTax, double & mTotal); 
     
    	void showDisplayOrder(string mBiscuitChoice, double mNumberOfBags, string mDryFoodChoice, double mNumberOfBoxes, double mSubTotal, double mSalesTax, double mTotal, string mName); 
     
    	double makeYourOwn(double myOrderPrice); 
     
    	int main(){ 
     
    		string name; 
    		string biscuitChoice; 
    		string dryFoodChoice; 
     
    		char orderToday; 
    		char makeOwnBiscuits; 
    		char biscuitOrder; 
    		char dryFoodOrder; 
    		double makeYourOwn; 
    		double myOrderPrice = 0; 
    		double numberOfBoxes = 0; 
    		double numberOfBags = 0; 
    		double biscuitPrice = 0; 
    		double dryFoodPrice = 0; 
    		double biscuitCost = 0; 
    		double dryFoodCost = 0; 
    		double subTotal = 0; 
    		double salesTax = 0; 
    		double total = 0; 
     
    		cout << "Welcome to Buster's Best Biscuits and Gourmet Dog Food." << endl; 
     
    		//Priming Read 
    		cout << "Would you like to place an order with us today Y/N" << endl; 
    		cin >> orderToday;
    		if(toupper(orderToday) == 'Y');
     
    			 	 
    		//While Loop 
     
    	while (orderToday == 'y'){ 
     
    		//Reinitialize Variables 
    		double subTotal = 0; 
    		double salesTax = 0; 
    		double total = 0; 
     
    		cin.ignore(); 
    		cout << "Please tell me your first name?" << endl; 
    		getline(cin, name); 
     
     
    		//Make your own Biscuits Function 
    		cout << name << " Would you like to make your own biscuits today? Y/N" << endl; 
    		cin >> makeOwnBiscuits; 
    		if (toupper(makeOwnBiscuits) == 'Y') 
    			
    			//Call Function Make your own biscuits
    			double makeYourOwn(double myOrderPrice); 
     
     
     
    		cout << name << " Would you like to order some Pre-Made biscuits today? Y/N" << endl; 
    		cin >> biscuitOrder; 
    		if (toupper(biscuitOrder) == 'Y') 
     
    			getBiscuits(biscuitChoice, numberOfBoxes, biscuitPrice); 
     
    		cout << name << " Would you like to order any Dry Dog Food today? Y/N" << endl; 
    		cin >> dryFoodOrder; 
    		if (toupper(dryFoodOrder) == 'Y') 
     
    			getDryFood(dryFoodChoice, numberOfBags, dryFoodPrice);  
     
    			showProcessData(myOrderPrice, biscuitPrice, dryFoodPrice, numberOfBoxes, numberOfBags, subTotal, salesTax, total); 
     
    			showDisplayOrder(biscuitChoice, numberOfBoxes, dryFoodChoice, numberOfBags, subTotal, salesTax, total, name); 
     
    		//Check to see if customer wants to order again 
    		cout << name << " Would you like to place another order with us today? Y/N" << endl; 
    		cin >> orderToday; 
     
    	} 
     
    	system("pause"); 
    	return 0; 
    } 
     
    void getBiscuits(string & mBiscuitChoice, double & mNumberOfBoxes, double & mBiscuitPrice){ 
    	system("cls"); 
    	int selection = 0; 
     
    	do{ 
    		system("cls"); 
     
    		cout << "1. Tiny Dog- under 5lbs, Tiny Biscuit - 5.00 " << endl; 
    		cout << "2. Small Dog- 5lbs to 8lbs, Small Biscuit - 6.00" << endl; 
    		cout << "3. Medium Dog- 8lbs to 20lbs, Medium Biscuit- 7.00" << endl; 
    		cout << "4. BIG DOG - 20lbs to 50lbs, Big Biscuit- 8.00" << endl; 
    		cout << "5. HUGE DOG - 50lbs and up, HUGE Biscuit-9.00" << endl; 
     
    		cout << "Please select a number from the menu above." << endl; 
    		cin >> selection; 
     
    		if (selection < 1 || selection >5){ 
    			cout << "Please select 1 through 5 ONLY" << endl; 
    			system("pause"); 
    		} 
    	} while (selection < 1 || selection >5); 
     
    	cout << "How many boxes of Biscuits would you like to order? \n " << endl; 
    	cin >> mNumberOfBoxes; 
     
    	switch (selection){ 
    	case 1: 
    		mBiscuitChoice = "Tiny Dog- under 5lbs, Tiny Biscuit"; 
    		mBiscuitPrice = 5.00; 
    		break; 
     
    	case 2: 
    		mBiscuitChoice = "Small Dog- 5lbs to 8lbs, Small Biscuit"; 
    		mBiscuitPrice = 6.00; 
    		break; 
     
    	case 3: 
    		mBiscuitChoice = "Meduim Dog- 8lbs to 20lbs, Meduim Biscuit"; 
    		mBiscuitPrice = 7.00; 
    		break; 
     
    	case 4: 
    		mBiscuitChoice = "BIG DOG - 20lbs to 50lbs, Big Biscuit"; 
    		mBiscuitPrice = 8.00; 
    		break; 
     
    	case 5: 
    		mBiscuitChoice = "HUGE DOG - 50lbs and up, HUGE Biscuit"; 
    		mBiscuitPrice = 9.00; 
    		break; 
     
    	default: 
    		cout << "Selection must be from 1 to 5 - selection changed to zero." << endl; 
    	} 
    } 
     
     
    void getDryFood(string & mDryFoodChoice, double & mNumberOfBags, double & mDryFoodPrice){ 
    	system("cls"); 
    	int selection = 0; 
     
    	do{ 
    		system("cls"); 
     
     
    		cout << "1. Tiny Dog- under 5lbs, Tiny Food - 10.00 " << endl; 
    		cout << "2. Small Dog- 5lbs to 8lbs, Small Food - 12.00" << endl; 
    		cout << "3. Medium Dog- 8lbs to 20lbs, Medium Food- 14.00" << endl; 
    		cout << "4. BIG DOG - 20lbs to 50lbs, Big Food- 18.00" << endl; 
    		cout << "5. HUGE DOG - 50lbs and up, HUGE FOOD-20.00" << endl; 
     
    		cout << "Please select a number from the menu above." << endl; 
    		cin >> selection; 
     
    		if (selection < 1 || selection >5){ 
    			cout << "Please select 1 through 5 ONLY" << endl; 
    			system("pause"); 
    		} 
    	} while (selection < 1 || selection > 5); 
     
    	cout << "How many bags of food would you like to order? \n " << endl; 
    	cin >> mNumberOfBags; 
     
    	switch (selection){ 
    	case 1: 
    		mDryFoodChoice = "Tiny Dog- under 5lbs, Tiny Food"; 
    		mDryFoodPrice = 10.00; 
    		break; 
     
    	case 2: 
    		mDryFoodChoice = "Small Dog- 5lbs to 8lbs, Small Food"; 
    		mDryFoodPrice = 12.00; 
    		break; 
     
    	case 3: 
    		mDryFoodChoice = "Meduim Dog- 8lbs to 20lbs, Meduim Food"; 
    		mDryFoodPrice = 14.00; 
    		break; 
     
    	case 4: 
    		mDryFoodChoice = "BIG DOG - 20lbs to 50lbs, Big Food"; 
    		mDryFoodPrice = 18.00; 
    		break; 
     
    	case 5: 
    		mDryFoodChoice = "HUGE DOG - 50lbs and up, HUGE FOOD"; 
    		mDryFoodPrice = 20.00; 
    		break; 
     
    	default: 
    		cout << "Selection must be from 1 to 5 - selection changed to zero." << endl; 
    	} 
    } 
     
    void showProcessData(double mMyOrderPrice, double mBiscuitPrice, double mDryFoodPrice, double mNumberOfBoxes, double mNumberOfBags, double & mSubTotal, double & mSalesTax, double & mTotal){ double mBiscuitCost = mBiscuitPrice * mNumberOfBoxes; double mDryFoodCost = mDryFoodPrice * mNumberOfBags; 
     
     
    	mBiscuitCost = mBiscuitPrice * mNumberOfBoxes; 
    	mDryFoodCost = mDryFoodPrice * mNumberOfBags; 
    	mSubTotal = mMyOrderPrice + mBiscuitCost + mDryFoodCost; 
    	mSalesTax = mSubTotal * .07; 
    	mTotal = mSubTotal + mSalesTax; 
    } 
     
    void showDisplayOrder(string mBiscuitChoice, double mNumberOfBags, string mDryFoodChoice, double mNumberOfBoxes, double mSubTotal, double mSalesTax, double mTotal, string mName){ 
     
    	cout << setprecision(2) << fixed; 
     
    	cout << "Thank you " << mName << " For your order." << endl; 
    	cout << "You ordered " << mNumberOfBags << " of the " << mBiscuitChoice << "and " <<  mNumberOfBoxes  <<" of the " <<  mDryFoodChoice  << endl; 
     
    	cout << "Your subtotal today is $" << mSubTotal << endl; 
    	cout << "Your sales tax today is $" << mSalesTax << endl; 
    	cout << "Your Grand Total today is $" << mTotal << endl; 
    }
    
    //Function Make your own biscuits
    double makeYourOwn(double myOrderPrice){
     
    		int selection = 0; 
    		double price = 0; 
     
    	cout << "Would you like to use Brown Rice? - Price $10.00 for 20 biscuits y/n"<< endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 10.00; 
     
    	cout << "would you liek to use Brown Rice and Salmon? - Price $12.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 12.00; 
     
    	cout << "Would you like to use Brown Rice and lamb? - Price $14.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 14.00; 
     
    	cout << "Would you like to use Brown Rice, Salmon, and lamb? - Price $16.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 16.00; 
     
    	cout << "would you like to use Green Eggs and Ham? - Price $18.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 18.00; 
     
    	cout << "would you like to use Steak and Lobster? - Price $20.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 20.00; 
     
    	return price;  
    }
    Makes a big difference, doesn't it? Now if you would just write your code to make it more readable. Like breaking long, long, long lines up. Like using a readable indent style (eg, Allman style) instead of that crappy K&R that hides open braces. Like being consistent with your indenting, especially considering that K&R depends absolutely on proper indenting.

    However, I do not understand this one part:
    Originally Posted by jtfish66
    But I can't get it to work.
    Just exactly what is that supposed to mean? Why won't you tell us? Do you think that this is Psychic Programming Friends Network? Do you really expect us to read your mind?

    What is it doing or not doing? We do not have time to waste with stupid guessing games. You need to tell us!

    Certainly you couldn't have tried to run it. Not with that error that it throws at Line 222:
    C:\otros\dcw>g++ -Wall jtfish01.cpp conio.c
    jtfish01.cpp: In function `int main()':
    jtfish01.cpp:36: warning: unused variable `double total'
    jtfish01.cpp:35: warning: unused variable `double salesTax'
    jtfish01.cpp:34: warning: unused variable `double subTotal'
    jtfish01.cpp:33: warning: unused variable `double dryFoodCost'
    jtfish01.cpp:32: warning: unused variable `double biscuitCost'
    jtfish01.cpp:26: warning: unused variable `double makeYourOwn'
    jtfish01.cpp: In function `void showDisplayOrder(basic_string<char,string_char_t
    raits<char>,__default_alloc_template<false,0> >, double, basic_string<char,strin
    g_char_traits<char>,__default_alloc_template<false,0> >, double, double, double,
    double, basic_string<char,string_char_traits<char>,__default_alloc_template<fal
    se,0> >)':
    jtfish01.cpp:222: `fixed' undeclared (first use this function)
    jtfish01.cpp:222: (Each undeclared identifier is reported only once
    jtfish01.cpp:222: for each function it appears in.)

    C:\otros\dcw>
    Here is the part of the program in question; Line 222 is the cout. BTW, I cleaned up the code there to make it a bit more readable, so that would throw the line numbers off when I'd compile it again:
    Code:
    void showDisplayOrder(string mBiscuitChoice, double mNumberOfBags, 
                string mDryFoodChoice, double mNumberOfBoxes, double mSubTotal, 
                double mSalesTax, double mTotal, string mName)
    { 
    	cout << setprecision(2) << fixed;
    You did not declare the variable, fixed. And if you did not intend for that to be a variable, then you messed up and you need to fix it. Don't ask me how -- in 23 years I never could cotton to iostreams.

    You need to fix that before you can even try to run it. Then you may want to review your code:

    Starting at Line 80:
    Code:
    		if (toupper(dryFoodOrder) == 'Y') 
     
    			getDryFood(dryFoodChoice, numberOfBags, dryFoodPrice);  
     
    			showProcessData(myOrderPrice, biscuitPrice, dryFoodPrice, numberOfBoxes, numberOfBags, subTotal, salesTax, total); 
     
    			showDisplayOrder(biscuitChoice, numberOfBoxes, dryFoodChoice, numberOfBags, subTotal, salesTax, total, name);
    The indenting tells us that you wanted to associate all three of those functions calls with the if-statement, but since you left out the braces only the first one, getDryFood(), is associated with the if. What do you want to do here? When you've finally decided that, then write what you mean! Which includes keep each and every line of code at its own level of indentation.

    BTW, the function prototypes and the main function are at the wrong level of indentation. You cannot afford to be so sloppy!

    And then there's this, starting at Line 240:
    Code:
    	if (toupper(selection) == 'Y'); 
    	price += 10.00; 
     
    	cout << "would you liek to use Brown Rice and Salmon? - Price $12.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 12.00; 
     
    	cout << "Would you like to use Brown Rice and lamb? - Price $14.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 14.00; 
     
    	cout << "Would you like to use Brown Rice, Salmon, and lamb? - Price $16.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 16.00; 
     
    	cout << "would you like to use Green Eggs and Ham? - Price $18.00 for 20 Biscuits y / n" <<endl; 
    	cin >> selection; 
    	if (toupper(selection) == 'Y'); 
    	price += 18.00;
    Do you really intend for none of those if-statements to have any effect? Do you really intend for those numbers to be added to price each and every time regard less of what the use inputs?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0
    when I try and run this program in Visual Studio 2013 it doesn't give me any errors a few warnings pass by almost to fast to read and then it launches.

    Last week I added the "While Loop" to be able to ask the customer if they wanted to order again or to have multiple customers ordering at the same time.

    This week I was supposed to add a return function that would ask the user if they wanted to make their own biscuits.

    I tried to use double makeYourOwn(double myOrderPrice) as my return function. With the non working IF statements as the ingredient choices and prices.
  10. #6
  11. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,253
    Rep Power
    2222
    Compile it first and then only run it when it compiles clean. It is very foolish to try to run a program without even knowing that it will compile. And far more foolish to persisting in trying to run it after you can very plainly see that it is not compiling cleanly.

    You still have offered no explanation at all of what "But I can't get it to work." is supposed to mean. How can you expect us to answer your questions when you won't give us the information that we need. Or without asking those questions -- those questions need to be specific; specific questions contain the information that we need.

    With the non working IF statements as the ingredient choices and prices
    You intended that code to not work???
  12. #7
  13. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo