Ground rules for the problem: • The only things you can use are the built-in min and max, as well as arithmetic/math operators. • You are not permitted to use the built-in sorting functions, nor write a loop or a function. In statistics, the median is the middle number in a sorted list of numbers. For four numbers, the median is taken to be the average of two numbers in the middle of the sorted list. For example, the data set 3,5,7, 12 (which is already sorted) has a median value of 7 = 6. In this problem, you will compute the median of 4 numbers, without being able to sort. Before program begins, the grader has set the following variables: your p: int, q: int, r: int, and s: int which are input numbers given in arbitrary order (not necessarily sorted). Your task is to write a program that sets the variable median: float to the median of these 4 numbers while obeying the ground rules. Examples: • For input numbers 7,5,3,12, the answer is 6.0. • For input numbers 2,1,5,11, the answer is 3.5. • For input numbers 99,8,0,24, the answer is 16.0. (Hint: Subtract, i.e., -, to remove unwanted numbers from a sum.)
Ground rules for the problem: • The only things you can use are the built-in min and max, as well as arithmetic/math operators. • You are not permitted to use the built-in sorting functions, nor write a loop or a function. In statistics, the median is the middle number in a sorted list of numbers. For four numbers, the median is taken to be the average of two numbers in the middle of the sorted list. For example, the data set 3,5,7, 12 (which is already sorted) has a median value of 7 = 6. In this problem, you will compute the median of 4 numbers, without being able to sort. Before program begins, the grader has set the following variables: your p: int, q: int, r: int, and s: int which are input numbers given in arbitrary order (not necessarily sorted). Your task is to write a program that sets the variable median: float to the median of these 4 numbers while obeying the ground rules. Examples: • For input numbers 7,5,3,12, the answer is 6.0. • For input numbers 2,1,5,11, the answer is 3.5. • For input numbers 99,8,0,24, the answer is 16.0. (Hint: Subtract, i.e., -, to remove unwanted numbers from a sum.)
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...
Related questions
Question
100%
Create median with only built-in min-max and arithmetic operations.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY