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
f.
A laborant in a laboratory does a number of antigen tests in one day. Write a program that
simulates the number of antigen tests done in a day in a laboratory, displays the number of
positives and negatives, and calculates the % of positives in one day. Your program needs
to first generate a random number that will show the number of tests done in a day. One
laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one).
Then for each of the tests, your program needs to generate a random number to show
whether they are positive or negative. In order to write this program, you need to have the
following three functions used by the main function:
test result (void): This function generates a test result. It should randomly
return either one or zero. 1 means positive test result and 0 means negative test result.
float positive percentage (int,int) : This function takes the total number of
positives and the total number of tests and returns the % of positives. For example, if the
number of tests done in one day is 50 and the number of positives is 25 then it should
return 50.0.
int
void display results (int,
positives, number of negatives and the percentage and prints the results on the screen.
int,
float): This function takes the number of
Sample Run:
Today you completed 50 tests and the results are as follows:
Test 1: p
Test 2: n
Test 3: p
.....
Test 50: p
Number of positives: 25
Number of negatives: 25
% of positives: 50.0%
Transcribed Image Text:f. A laborant in a laboratory does a number of antigen tests in one day. Write a program that simulates the number of antigen tests done in a day in a laboratory, displays the number of positives and negatives, and calculates the % of positives in one day. Your program needs to first generate a random number that will show the number of tests done in a day. One laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one). Then for each of the tests, your program needs to generate a random number to show whether they are positive or negative. In order to write this program, you need to have the following three functions used by the main function: test result (void): This function generates a test result. It should randomly return either one or zero. 1 means positive test result and 0 means negative test result. float positive percentage (int,int) : This function takes the total number of positives and the total number of tests and returns the % of positives. For example, if the number of tests done in one day is 50 and the number of positives is 25 then it should return 50.0. int void display results (int, positives, number of negatives and the percentage and prints the results on the screen. int, float): This function takes the number of Sample Run: Today you completed 50 tests and the results are as follows: Test 1: p Test 2: n Test 3: p ..... Test 50: p Number of positives: 25 Number of negatives: 25 % of positives: 50.0%
Expert Solution
steps

Step by step

Solved in 4 steps

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