Int Mchoice Int Choiceresult Int Result Cout Welcome Machine Q43797043
int MChoice (int choiceResult)
{
int result;
cout<< “Welcome to my Machine”<<endl;
cout<<“Please choose from the following options.n”;
cout<<“0. No pencils for me today.n”;
cout<<“1. Purchase pencils.n”;
cout<<“2. Check inventory level.n”;
cout<<“3. Check change level.n”;
int choice;
cin>>choice;
while(cin.fail())
{
cin.clear();
cin.ignore(50,’n’);
cout<<“Input must be numeric. Try againn”;
cin >> choice;
}
while (choice <= -1 || choice >= 4)
{
cout<<“Invalid Input.n”;
cout<<“Try again from the menu: “;
cin >>choice;
}
result = choice;
return result;
}
i am trying to convert this into swift programming(background)
Expert Answer
Answer to int MChoice (int choiceResult) { int result; cout…
OR