• Language

    Pascal

  • Description

    Create an Ideal Weight application that accepts input for:
    - A person's name
    - A person's height
    -The system of measurement they wish to use (metric or imperial).
    The program will use the person's height to calculate his/her ideal healthy weight using a formula produced from the formula for body mass index (BMI). The BMI is a statistical measurement which compares a person's weight and height.
    Though it does not actually measure the percentage of body fat, it is a useful tool to estimate a healthy body weight based on a person s height. According to the BMI, a value of 18.5 to 25 is considered healthy.
    In this program, allow the user to use either the imperial measurements or metric to calculate a healthy weight.
    Metric: Weight (kg) = height (metres) × height (metres) × 25
    Imperial: Weight (pounds) = height (inches) × height (inches) × 25 ÷ 703

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
program IdealWeightCalculator;
uses crt;

var system_of_measurement : integer;
var healthy_weight, height : real;
var person_name : string;
begin
    write ('Enter the person name: ');
    readln (person_name);
    write ('Enter the value of height: ');
    readln (height);
    writeln ('Select the value of system of measurement.');
    writeln ('    1.- metric');
    writeln ('    2.- imperial');
    write ('    : ');
    repeat
        readln (system_of_measurement);
        if (system_of_measurement<1) or (system_of_measurement>2) then
            write ('Wrong value. Please, enter it again.: ');
    until (system_of_measurement>=1) and (system_of_measurement<=2);
    if system_of_measurement=1 then
        begin
            writeln ('kg');
            healthy_weight := height*height*25;
        end
    else
        begin
            writeln ('pounds');
            healthy_weight := height*height*25/703;
        end;
    if healthy_weight>25 then
        begin
            writeln ('You have to lose weight.');
        end;
    if (healthy_weight>=18.5) and (healthy_weight<=25) then
        begin
            writeln ('Your weight is considered healthy.');
        end;
    if healthy_weight<18.5 then
        begin
            writeln ('You have to win weight.');
        end;
    writeln ('Person name: ', person_name);
    writeln ('Value of healthy weight: ', healthy_weight:0:6);
    writeln;
    write ('Press any key to finish . . . ');
    readkey;
end.