Hi the code is giving issues. Please help me fix. I have posted the code and project prompt. Thank you!!!!!! **PROMPT** Please write a C++ program that will accept 3 integer numbers from the user, and then output these 3 numbers in ascending order, their sum, and their average. You must stop your program when the first number from the user is -999. Program Design Specifications and Regulations:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hi the code is giving issues. Please help me fix. I have posted the code and project prompt. Thank you!!!!!!

**PROMPT**

Please write a C++ program that will accept 3 integer numbers from the user, and then output these 3 numbers in ascending order, their sum, and their average. You must stop your program when the first number from the user is -999. Program Design Specifications and Regulations:
(1) You must use your full name on your welcome and thank-you messages.
(2) You must specify 3 prototypes in your program (before main( ) ) for 3 functions as follows: int max(int p, int q, int r); // prototype to return maximum of p, q, r int min(int p, int q, int r); // prototype to return minimum of p, q, r int mid(int p, int q, int r); // prototype to return middle of p, q, r
(3) You must define the above three integer functions properly in your program after main( ). If you define those three functions before main( ), you should not specify those 3 prototypes.
(4) You must NOT use any C++ existing or pre-defined functions in your program.
(5) You must fully test your program to make sure that these three functions are working perfectly for any 3 numbers in any sequence.
(6) How to show those 3 numbers (p, q, r) in ascending order without sorting them at all? The answer is that you show their minimum number, middle number, and maximum number.
(7) How to check and detect that q is the middle number among p, q, and r? The answer is that you need to consider two cases as follows:

if (q >= p && q <= r) return q ; // case 1: r, q , p i.e., r <= q <= p

if (q >= r && q <= p) return q ; // case 2: p, q, r i.e., p <= q <= r


**CODE**

#include <iostream>
using namespace std;

int min(int, int, int);
int mid(int, int, int);
int max(int, int, int);

int main()
{
int p, q, r;
int testCase = 0;

cout << "Welcome to the Number Game of Joe!" << endl;

while(true)
{
cout << ++testCase << " ========================= " << endl;

cout << "Please enter 3 integer numbers in any order (-999 to stop): ";
cin >> p >> q >> r;

if (p == -999 || q == -999 || r == -999)
{
cout << ++testCase << " ========================= " << endl;
cout << "Thank you for playing this Number Game of Joe!" << endl;
cout << ++testCase << " ========================= " << endl;
break;
}

int sum = p + q + r;
int average = sum/3;

cout << "You entered 3 numbers: " << p << " , "<< q << "," << r << endl;
cout << "These 3 numbers in order are: " << min(p, q, r) << ", " << mid(p, q, r) << mid(p, q, r) << ", " << max(p, q, r) << endl;
cout << "The sum is " << sum << " and the average is " << average << endl;
}

return 0;

int max(int p, int q, int r)
{
int max = 0;
if (p > q && p > r)
max = p;

else if (q > p && q > r)
max = q;

else
max = r;

return max;
}

int mid(int p, int q, int r)
{
int mid = 0;
if ((q >= p && q <= r) || (r <= q && q <= p)
mid = q;

else if ((q <= p && p <= r)) || (r <= p && p <= q))
mid = p;
else
mid = r;

return mid;
}

int min(int p, int q, int r)
{
int min = 0;
if (p < q && p < r)
min = p;

else if (q < p && q < r)
min = q;

else
min = r;

return min;
}
}

Please enter 3 integer numbers in any order (-999 to stop) : 7 9 6
You just entered 3 numbers: 7, 9, 6
These 3 numbers in order are 6, 7, 9
The sum is 22 and the average is 7
5=
Please enter 3 integer numbers in any order (-999 to stop) : 7 9 7
You just entered 3 numbers: 7, 9, 7
These 3 numbers in order are 7, 7, 9
The sum is 23 and the average is 7
6=
Please enter 3 integer numbers in any order (-999 to stop) : 9 9 9
You just entered 3 numbers: 9, 9,9
These 3 numbers in order are 9, 9, 9
The sum is 27 and the average is 9
7=
Please enter 3 integer numbers in any order (-999 to stop) : -999 0 0
8=====
Thank you for playing this Number Game of Dr. Simon Lin! Emust use your name!
9=======
Transcribed Image Text:Please enter 3 integer numbers in any order (-999 to stop) : 7 9 6 You just entered 3 numbers: 7, 9, 6 These 3 numbers in order are 6, 7, 9 The sum is 22 and the average is 7 5= Please enter 3 integer numbers in any order (-999 to stop) : 7 9 7 You just entered 3 numbers: 7, 9, 7 These 3 numbers in order are 7, 7, 9 The sum is 23 and the average is 7 6= Please enter 3 integer numbers in any order (-999 to stop) : 9 9 9 You just entered 3 numbers: 9, 9,9 These 3 numbers in order are 9, 9, 9 The sum is 27 and the average is 9 7= Please enter 3 integer numbers in any order (-999 to stop) : -999 0 0 8===== Thank you for playing this Number Game of Dr. Simon Lin! Emust use your name! 9=======
Welcome to this Number Game of Dr. Simon Lin!
Emust use your name!
Please enter 3 integer numbers in any order (-999 to stop) :7 6 5
You just entered 3 numbers: 7, 6, 5
These 3 numbers in order are 5, 6, 7
The sum is 18 and the average is 6
2-
Please enter 3 integer numbers in any order (-999 to stop) : 3 4 5
You just entered 3 numbers: 3, 4, 5
These 3 numbers in order are 3, 4, 5
The sum is 12 and the average is 4
3=
Please enter 3 integer numbers in any order (-999 to stop) : 5 9 7
You just entered 3 numbers: 5, 9, 7
These 3 numbers in order are 5, 7, 9
The sum is 21 and the average is 7
4=
Transcribed Image Text:Welcome to this Number Game of Dr. Simon Lin! Emust use your name! Please enter 3 integer numbers in any order (-999 to stop) :7 6 5 You just entered 3 numbers: 7, 6, 5 These 3 numbers in order are 5, 6, 7 The sum is 18 and the average is 6 2- Please enter 3 integer numbers in any order (-999 to stop) : 3 4 5 You just entered 3 numbers: 3, 4, 5 These 3 numbers in order are 3, 4, 5 The sum is 12 and the average is 4 3= Please enter 3 integer numbers in any order (-999 to stop) : 5 9 7 You just entered 3 numbers: 5, 9, 7 These 3 numbers in order are 5, 7, 9 The sum is 21 and the average is 7 4=
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY