Algorithm That Sort Three Numbers From The Smallest To The Largest.docx

  • Uploaded by: Novi Thetha Sella
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Algorithm That Sort Three Numbers From The Smallest To The Largest.docx as PDF for free.

More details

  • Words: 1,403
  • Pages: 12
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

Related Documents


More Documents from ""