Module: Arithmetic expressions


Problem

5 /7


Recording arithmetic operations

Theory Click to read/hide

Recording arithmetic operations
Suppose we need to calculate an expression written in mathematical form in the following  way: 
\({ 2\ \cdot\ 17.56^2 \over {7\ \cdot\ 2.47\ \cdot\ 0.43}}\)

Rules for writing arithmetic expressions
1. An expression can contain numbers, other variable names, operation signs, parentheses, function names, arithmetic operations and their signs (+, -, *< /code>, /, div, mod).
2. The separator between integer and fractional parts is a dot.
3. The expression is written in one line (linear notation of expressions), characters are sequentially lined up one after another, ALL signs of operations are put down, parentheses are used.< br />
Thus, following the rules for writing arithmetic expressions, we must translate the given fraction (mathematical notation) into a linear notation, that is, write the fraction in one line. Since the numerator and denominator are complex (that is, they contain two or more factors), when writing an expression in a linear form, it is necessary to take the numerator and denominator in brackets.
Thus, the linear notation of such an expression will look like this:
 
(2*17.56*17.56)/(7*2.47*0.43)

Let's write a program to calculate the value of this expression. To do this, let's define the input and output data.

Input
Because we know all the values, then nothing needs to be entered from the keyboard, therefore there will be no input values.

Imprint
The program should display the result of the given arithmetic expression (the result can be saved to some variable, or immediately displayed on the screen).

In the program, we will immediately display the result on the screen. Since we have a fraction, the result will be a real number. 
  begin     writeln((2*17.56*17.56)/(7*2.47*0.43):9:6); end. Run the program on your computer and make sure it returns 82.949843.

 

Problem

Write a program that calculates the value of an expression using a known formula.

\({x + y\over {x +1}}-{x\cdot y-12 \over 34 + x}\)
x and y are integer type variables, entered from the keyboard.

The program should output one number - the result of the expression evaluation.

Hint: don't forget to get a real number when dividing!