1. Other
  2. Other
  3. construct a solution algorithm for the following problems your question...

Question: construct a solution algorithm for the following problems your question...

Question details

Construct a solution algorithm for the following problems. Your question solution should contain:

  • Defining problem

  • Pseudo code algorithm
    use as java code in eclipse

  • Desk check of the algorithm

(Three test cases for each question. Two valid and one error test case if appropriate)

 

Question 1

A clinic requires a program to calculate the body mass index (BMI) and display the BMI value and status of a patient. Develop a program to accept the height and weight of a patient, calculate the BMI and display BMI value and status of a patient.

page1image2848072688

BMI = weight in kg/height2 

        BMI         Status
Below 24 (inclusive) Under weight 
Above 24 to 29 (inclusive) Healthy 
Above 29 to 34 (inclusive) Overweight 
Above 34 Obese


page1image2847976448

Error check required: negative height and weight.


Assume user always enter number.


If the user enter invalid height or weight, print error message and ends the program.

 

 

 

 


example answer :

Defining diagram :

 

Input

Processing

Output

 

Patient’s details

-       Name

-       Height

-       Weight

 

 

Display Heading

Read patient’s detail

Calculate BMI

Print BMI value and patient’s status.

 

 

Patient’s details

-       BMI value

-       Patient’s status

 

 

Solution algorithm :

 

 

Print_BMI_results

            Display ‘BODY MASS INDEX’ heading

            DOWHILE more records exist

                        Read patient detail

                               BMI = (Weight_kg/ ((Height_cm ^2)*0.0001))

                        IF BMI <= 24 THEN

                                    status = ‘Under Weight’

                        ELSE IF BMI >= 29 THEN

                                    status = ‘Healthy’

                        ELSE IF BMI >= 34 THEN

                                    status = ‘Overweight’

                        ELSE IF BMI > 34 THEN

                                    status = ‘Obese’

            

                        ENDIF

                        Display patient_BMIValue, patient_status

            ENDDO

END

 

 

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution