## anonymous one year ago Please can someone help me with this using pseudocode and algorithm to compute the model: A = √(s-b)(s-b)(s-c) S = a+b+c/2 with explanation

1. anonymous

step 1: Define a function (I am using this in the most general sense) ---lets call it CalculateArea ---which accepts inputs of type integer s, b and c.

2. anonymous

The BODMAS/BIDMAS/BIRDMAS rule tells you: do what is in the brackets first, so Step 2. subtract the value b from s and store in a temporary variable called A1 subtract the value b from s and store in a temporary variable called A2 subtract the value c from s and store in a temporary variable called A3 You will then need to multiply these values according to your formula so: Step 3: multiply A1, A2 and A3 and store the result in a temporoary variable called M1 Finally, you will need to get the square root of M1, the result of multiplying these together Step 4: get the square root of M1 and assign this to the variable A Finally you will need to print out the value Step5: Print the value of A to the screen. leave out my comments and just include the steps, and you will have the pseudocode for the first equation.

3. anonymous

4. anonymous

From the pseudocode, we can deduce the algorithm as follows, (remember an algorithm is just a series of steps). Imagine you are trying to tell a computer how to do this. Algorithm: create a function called CalculateArea which accepts 3 integers called s,b,c A1 = s-b A2 = s-b A3 = s-c M1 = A1 x A2 x A3 A= sqrt (M1) Print A;

5. mathmate

@ubah Isn't the Hero's formula meant to be: $$\color{red}{s} = \color{red}{(a}+b+c\color{red}{)}/2$$ $$A = \color{red}{\sqrt{\color{black}{(s-\color{red}{a})(s-b)(s-c)}}}$$ In programming, - upper/lower case count - brackets count - names of variables count - order of statements counts The compiler is not very forgiving, it does exactly what you tell it to do.