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

o   (Three test cases for each question)

o   (Two valid and one error test case if appropriate)

_____________________________________________________________________________________

The Meteorological service requires a program to allow the operator to enter the rainfall level. The program keep accepting the rainfall level until a negative or zero value is entered. The program will keep displaying the current min, max and running average rainfall level after an entry is made. The program terminates by the operator entering a negative value or zero and displaying the total number of entries made.

Sample output. The text in bold is the user inputs.
(Note you need not make the user inputs bold in actual program)

 Enter rainfall :  3.2 Min :  3.2     Max :  3.2     Ave :  3.2   Enter rainfall :  3.8 Min :  3.2     Max :  3.8     Ave :  3.5   Enter rainfall :  2 Min :  2.0     Max :  3.8     Ave :  3.0   Enter :  -1 Rainfall entries made :  3

No error check required.
Assume user always enter number.

Defining diagram :

 Input Processing Output Patient’s details -       Name -       Height (cm) -       Weight (kg) 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 CALCULATOR 1          Set Statement to True 2          Set Patient Status to blank 3          Read patient name, weight in kg and height in cm  4          IF patient weight < 0 THEN                         Patient Status = ‘Incorrect Weight’                         Statement = False             ENDIF   5          IF patient height < 0 THEN                         Patient Status = ‘Incorrect Height’                         Statement = False             ENDIF   6          IF Statement = True THEN 7                      BMI =  patient weight/(patient height*patient height)*0.0001 8                      IF BMI <= 25 THEN                                     Patient Status = ‘Under Weight’                         ELSE IF BMI <= 29 THEN                                     Patient Status = ‘Healthy’                         ELSE IF BMI <= 34 THEN                                     Patient Status = ‘Overweight’                         ELSE IF BMI > 34 THEN                                     Patient Status = ‘Obese’                         ENDIF 9                                  Print Patient BMI Value, Patient Status                         ENDIF END

Desk checking :

1.     Input data.

 First data set Second data set Third data set Name Sin Yang Charles Marcus Weight 70 120 -25 Height 180 172 183

2.     Expected result.

 First data set Second data set Third data set BMI 70/((180^2)*0.0001) = 21.60 120/((172^2)*0.0001) = 40.56 - Status Underweight Obese Error Message

3.     Set up a table of variable names and then pass each test data set through the solution algorithm, statement by statement.

 Statement number Weight Height BMI Value (Math.round) Statement Status First pass 1,2 True Blank 3 70 80 4,5 True 6,7 8 70/((180^2)*0.0001) = 22 9 70Display 80Display 22Display UnderweightDisplay Second pass 1,2 True Blank 3 120 172 4,5 True 6,7 8 120/((172^2)*0.0001) = 41 9 120Display 172Display 41Display ObeseDisplay Third pass 1,2 True Blank 3 -25 183 4,5 False Incorrect Height 6,7 8 9