Novi Krisdayanti 17029171 Ataya Aufa Saleh 17029084 Monica Junaidi 17029163 Efrida Yana Nasution 17029013 Ayu Sangrila 17029087
Algorithm and Programming
Create an algorithm for the following problem : 1. Calculate discriminant with the formula b2-4ac DESCRIPTIVE SENTENCE The Algorithm calculate the discriminant. a,b,c are known. Determine discriminant with the formula b2-4ac Description : 1. Read π 2. Read π 3. Read π 4. π· = π 2 β 4ππ 5. Shown the discriminant.
PSEUDO CODE The algorithm calculate the discriminant. Discriminant with π, π, π are known. Determine the discriminant. Declaration : π, π, π, π· : real Description : Read (π, π, π) π· = π 2 β 4ππ Write (π·)
FLOW CHART Start
π, π, π?
π· = π 2 β 4ππ
Shown D
End
2. Calculate the roots of quadratic equation DESCRIPTIVE SENTENCE The algorithm to calculate the roots of quadratic equation. π, π, π are known. Determine or calculate the roots of quadratic equations. Description : 1. Read π 2. Read π 3. Read π 4. Calculate the roots of quadratic equation π₯1,2 =
βπ Β± βπ 2 β4ππ
5. Shown the roots
PSEUDO CODE The algorithm to calculate the roots of quadratic equation
2π
π, π, π are known. Determine or calculate the roots of quadratic equations. Declaration : π₯1,2 , π, π, π : real Description : Read (π, π, π) π₯1,2 =
βπ Β± βπ 2 β 4ππ 2π
Write (π₯1,2 )
FLOW CHART
Start
π, π, π
π₯1,2 =
βπ Β± βπ 2 β 4ππ 2π
π₯1,2
End
3. Determine the letter of the student value from the final value of the number obtained for a course DESCRIPTIVE SENTENCE The Algorithm to determine the letter of the student value from the final value of the number obtained for a course. Description: 1. Read the final value 2. If the value in the range 85-100, write A, then 3. If the value in the range 80-84,99, write A-, then 4. If the value in the range 75-79,99, write B+, then 5. If the value in the range 70-74,99, write B, then 6. If the value in the range 65-69,99, write B-, then 7. If the value in the range 60-64,99, write C+, then 8. If the value in the range 55-59,99, write C, then 9. If the value in the range 50-54,99, write C-, then 10. If the value in the range 45-49,99, write D, then 11. If the value in the range less then 45 write E 12. Shown the result
PSEDUO CODE : Declaration : n: whole number(0-100) m: string Description : 1. Read n 2. If n β₯ 85, write A. Then 3. If 80β€n<85, write A-. Then 4. If 75β€n<80, write B+. Then 5. If 70β€n<75, write B.Then 6. If 65β€n<70, write B-. Then 7. If 60β€n<65, write C+. Then 8. If 55β€n<60, write C. Then 9. If 50β€n<55, write C-. Then 10. If 45β€n<50, write D. Then 11. If n< 45, write E.
4. Change the temperature unit between the size of Celcius, Fahrenheit, and Reamur. DESCRIPTIVE SENTENCE Algorithm That Convert The Reamurtemperature Scale To The Celcius And Fahrenheit Temperature Scale ο°C, ο°R, ο°F are number that given. We convert the reamur temperature scale to the celcius and fahrenheit temperature scale. Description : 1. Read ο°R. 5
2. If reamur convert to celcius, the formula isο°πΆ = 4 Γ Β°π
, write ο°C. then, 9
3. If reamur convert to Fahrenheit, the formula isβ = 4 Γ Β°π
, write ο°F. Then 4. Write R
PSEDUO CODE : Algorithm That Convert The Reamur Temperature Scale To The Celcius And Fahrenheit Temperature Scale ο°C, ο°R, ο°F are number that given. We convert the reamur temperature scale to the celcius and fahrenheittemperature scale. Declaration : ο°F, ο°R, ο°C, T : Real Description : 1. Read ο°R. 5
2. If ο°C, ο°πΆ = 4 Γ Β°π
, write ο°C 9
3. Then, if ο°F, β = 4 Γ Β°π
, writeο°F 4. Then, write ο°R
FLOW CHART
Start
ο°R
Convert to ο°C ?
YES
5 Γ Β°π
4
ο°C 5 ΓΒ° 4
NO
Convert to ο°F ?
NO
ο°R
End
YES
9 Γ Β°π
4
ο°F 5 ΓΒ° 4
DESCRIPTIVE SENTENCE : Algorithm that convert the celcius temperature scale to the reamur and fahrenheit temperature scale. ο°C, ο°R, ο°F are number that given. We convert the celcius temperature scale to the reamur and Fahrenheit temperature scale. Description : 1. Read ο°C. 4
2. If reamur convert to reamur, the formula isο°π
= 5 Γ Β°πΆ , write ο°R. then, 9
3. If reamur convert to Fahrenheit, the formula isβ = 5 Γ Β°πΆ, write ο°F. Then 4. Write Β°C.
PSEDUO CODE : Algorithm that convert the celcius temperature scale to the reamur and fahrenheit temperature scale. ο°C, ο°R, ο°F are number that given. We convert the celcius temperature scale to the reamur and Fahrenheit temperature scale. Declaration : ο°F, ο°R, ο°C, T : Real Description : 1. Read ο°C. 4
2. If ο°R, ο°π
= 5 Γ Β°πΆ , write ο°R. 9
3. Then, if ο°F, β = 5 Γ Β°πΆ, writeο°F. 4. Then, write ο°C.
F
Start
ο°C
Convert to ο°R ?
YES
4 Γ Β°πΆ 5
ο°R 5 ΓΒ° 4
NO
Convert to ο°F ?
NO
ο°C
End
YES
9 Γ Β°πΆ 5
ο°F 5 ΓΒ° 4
DESCRIPTIVE SENTENCE : Algorithm that convert the fahrenheit temperature scale to the celcius and fahrenheit temperature scale. ο°C, ο°R, ο°F are number that given. We convert the Fahrenheit temperature scale to the celcius and reamur temperature scale. Description : 5. Read ο°F. 5
6. If fahrenheit convert to celcius, the formula isο°πΆ = 9 Γ Β°πΉ , write ο°C. then, 9
7. If fahrenheit convert to reamur, the formula is Β°π
= 4 Γ Β°πΉ, write ο°R. Then 8. Write Β°F. PSEDUO CODE : ALGORITHM THAT CONVERT THE FAHRENHEIT TEMPERATURE SCALE TO THE CELCIUS AND FAHRENHEIT TEMPERATURE SCALE ο°C, ο°R, ο°F are number that given. . We convert the Fahrenheit temperature scale to the celcius and reamur temperature scale. Declaration : ο°F, ο°R, ο°C, T : Real Description : 5. Read ο°F. 5
6. If ο°C, ο°πΆ = 9 Γ Β°πΉ , write ο°C. 4
7. Then, if ο°R, Β°π
= 9 Γ Β°πΉ, writeο°R. 8. Then, write ο°F.
Start
ο°F
Convert to ο°C ?
YES
5 Γ Β°πΉ 9
ο°C 5 ΓΒ° 4
NO
Convert to ο°R ? NO
ο°F
End
YES
4 Γ Β°πΉ 9
ο°R 5 ΓΒ° 4
DESCRIPTIVE SENTENCE : ALGORITHM THAT SORT THREE NUMBERS FROM THE SMALLEST TO THE LARGEST a, b,c are number that given. We Sort the the number from the smallest to the largest. Description : 9. Read a,b,c 10. If a is a number that the smallest from the other number, write a firstly, after that read b,c. if b less than c, write b, and last write c.if c less than b , write c, and last write b. Then, 11. If b is a number that the smallest from the other number, write b firstly, after that read a,c. if a less than c, writea, and last write c. if c less than a, write c, and last write a. Then, 12. If c is a number that the smallest from the other number, write c firstly, after that read a,b. if a less than b, write a, and last write b. if b less than a , write b, and last write a. 13. Shown the result.
PSEDUO CODE : ALGORITHM THAT SORT THREE NUMBERS FROM THE SMALLEST TO THE LARGEST a, b,c are number that given. We Sort the the number from the smallest to the largest. Declaration : a, b, c : Real Description : 1. Read (a,b,c) 2. If a
FLOW CHART : START
(a,b,c)
a < b? a < c?
YES
a
(b,c)
YES b
b
c
NO NO
c b < c? b
YES
b
(a,c)
b YES
a
a
c
NO
c
NO
c < a? c
c
(a,b)
a YES
a
a NO
b
a
b
END