Hi Guys,
I'm working on the same assignment, and this question is really confusing me.
I get that we have to use a void function with two parameters (one string and one int) but I cannot get the while condition in the do..while loop to execute.
This is what I've managed so far but I know I'm making lots of mistakes.
The text in Red was given to us in the assignment and we have to work out the void function. This is only step one of the question and its frustrating cos I have nothing else to work with.
Does this make sense to anyone else???
Thanks for letting me rant, I needed to or I would be killing someone right now
PROGRAM:
//Assignment 2 - Question 5
#include <iostream>
#include <string>
using namespace std;
// void inputAndValidate function.
void inputAndValidate(string & sort, int & number)
{
do
{
cout << "Enter the type of cake ordered " << endl;
cout << "(chocolate, carrot, custard, fruit or coffee): ";
cin >> sort;
cout << "Enter the number of cakes ordered: ";
cin >> number;
}
while ((sort != 'chocolate') && (sort != 'carrot') && (sort != 'custard') && (sort != 'fruit') && (sort != 'coffee')
}
int main( )
{
string sort;
int number;
inputAndValidate(sort, number);
cout << number << " " << sort << " cake(s). " << endl;
return 0;
}