Given the following function definitions, write matching precondition and postcondition comments. void swap(int& x, int& y) { int temp; temp = x; x = y; y = x; } void displayOrder(string order, double price, int num) { cout << "Your order of " << num << " " << order << "(s) comes out to $" << price * num << endl; } int processChoice(char choice, int n, int r) { int result = r; if (choice == 'P' || choice == 'p') result += n; else if (choice == 'S' || choice == 's') result -= n; else if (choice == 'M' || choice == 'm') result *= n; else if (choice == 'D' || choice == 'd') result /= n; else result = 0; return result; }
Given the following function definitions, write matching precondition and postcondition comments.
void swap(int& x, int& y)
{
int temp;
temp = x;
x = y;
y = x;
}
void displayOrder(string order, double price, int num)
{
cout << "Your order of " << num << " " << order << "(s) comes out to $" << price * num << endl;
}
int processChoice(char choice, int n, int r)
{
int result = r;
if (choice == 'P' || choice == 'p')
result += n;
else if (choice == 'S' || choice == 's')
result -= n;
else if (choice == 'M' || choice == 'm')
result *= n;
else if (choice == 'D' || choice == 'd')
result /= n;
else
result = 0;
return result;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)