Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For a particular illness a patient should take 3 drugs every day: Drug A, drug B and drug C. According to his age and his
For a particular illness a patient should take 3 drugs every day: Drug A, drug B and drug C. According to his age and his gender the following table describes the necessary quantity Write down a program that allows to calculate and print the quantities of the three drugs if a user enters his age and his gender. Age range A B age = 60 Figure 1: How to calculate drug quantity 30 mg 40 mg 35 mg 2A mg 4A mg 3A mg 20+B - 1.5K 40 + 2B - 3K 30 + B - 2.5K K= A/2 for Male ('M"), Al 3 for Female ('F') Write 3 functions and a main function. Do not use any library other than stdio. Function 1: (20 pts) Function name: CalculateA Function parameter: 1 int parameter named "age" Return type: double See Figure 1 to figure out what it does. Function 2: (20 pts) Function name: CalculateB Function parameter 1 int parameter named "age" Return type: double See Figure 1 to figure out what it does. Function 3: (40 pts) Function name: Calculatec Function parameter 1 int parameter named "age" and 1 char parameter named "gender" Return type: double See Figure 1 to figure out what it does. The main function: Ask 2 values from the user: age (int) and gender (char). (5 pts) Call the functions to calculate the quantity of each drug the patient should take depending on his age and gender. (10 pts) Print the quantity of each drug as in the examples below. (5 pts) Do the printf and scanf operations only in the main function. Examples: dergonul@DESKTOP-3320H5K: $ ./a.out 5 M 30.eeeeee 60.000000 57.500000 dergonul@DESKTOP-3J20H5K: $ ./a.out 15 M 40.eeeeee 160.eeeeee 300.eeeeee dergonul@DESKTOP-3J2QH5K: $ ./a.out 65 M 35.000eee 105.000000 91.250000 dergonul@DESKTOP-3J2QH5K: $ ./a.out 5 F 30.000000 60.000000 65.000000 dergonul@DESKTOP-3J2QH5K: $ ./a.out 15 F 40.000000 160.000000 320.000000 dergonul@DESKTOP-3J2QH5K: $ ./a.out 65 F 35.eeeeee 105.000000 105.833333
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started