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;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps