Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6.6. A program stores sales amounts in two int variables named marySales and jim

ID: 3633083 • Letter: 6

Question

6.6. A program stores sales amounts in two int variables named marySales and jimSales. Write the c++ code to display the message "Mary and Jim sold the same amount" when both variables contain the same number. If both variables contain different numbers, the code should compare both numbers and then display either the message : Mary sold more than Jim" or the message " Jim sold more than Mary".
This is what i have.

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

int main()
{
//declare variables
int marySales;
int jimSales;
double sameSales,differentSales;

//User inputs
cout << "Enter Marys sales: ";
cin >> marySales;
cout << "Enter Jims Sales: ";
cin >> jimSales;

//Calculate the difference
if (marySales>jimSales)
{highSales=marySales;
lowSales=jimSales;
}
else
{highSales=jimSales;
lowSales=marySales;
}
//end of if
cout<<"High Sales: "<<highSales<<endl;
cout<<"Low Sales: "<<lowSales<<endl;
system("pause");
return 0;
} //end of main function
<code>

Explanation / Answer

Your program is fine, except it does not give the correct output as per the question. Several bits can be left out though like assigning highSales and lowSales to the respective sales of Mary and Jim. Instead, you can simply do this. #include #include using namespace std; int main() { //declare variables, no need for sameSales and diffSales int marySales; int jimSales; //User inputs cout > marySales; cout > jimSales; //check which is larger, or if they are equal if (marySales>jimSales) {cout