0% found this document useful (0 votes)
7 views10 pages

Data Type Identification and Conversion Programs

The document presents a series of exercises for reinforcing knowledge about data types and variables. In the first exercises, the user must identify which presented data are of the integer, real, literal, or logical type. In the following exercises, the user must indicate which names are valid for variables and develop algorithms, diagrams, and coding in structured Portuguese for programs that solve problems such as temperature conversion, volume calculation, fuel consumption, and others.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Data Type Identification and Conversion Programs

The document presents a series of exercises for reinforcing knowledge about data types and variables. In the first exercises, the user must identify which presented data are of the integer, real, literal, or logical type. In the following exercises, the user must indicate which names are valid for variables and develop algorithms, diagrams, and coding in structured Portuguese for programs that solve problems such as temperature conversion, volume calculation, fuel consumption, and others.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Consolidation Exercises

Indicate with an X which of the presented data are of the Integer type.
(X) 1000
( ) “)”
-900
True.
(X) -456
(X) 34
House 8
(X) 0
( ) .False.
( ) -1.56
Indicate with an X which of the data are of the Real type.
(X) -678
0.87
-9.12
True.
(X) -456
-99.8
Five
(X) 45.8976
False.
(X) -1.56
Indicate with an X which of the following data are of the Literal type.
( ) 678
0.87
-9.12
True
minus four hundred fifty-six

( ) -99.8
Five
( ) 45.8976
.False.
( ) 1.56
Indicate with an X which of the data are of the Logical type.
( ) -678
0.87
-9.12
True.
( ) -456
(X) .V.
Five
(X) . False.
(X) .F.
( ) -1.56
Mark with an X the valid names for a variable
(X) ADDRESS
( ) 21BRAZIL
( ) PHONE$COM
(X) USERNAME
(X) USER_NAME
( ) NAME*USER
( ) END*A-6
(X) CITY3
( ) #HEAD

6. Develop the algorithms, flowcharts, and coding in Portuguese


structured of the following programs:
a. Read a temperature in degrees Celsius and present it converted to degrees.
Fahrenheit. The conversion formula is F ← (9 * C + 160) / 5, where F is
temperatura em Fahrenheit e C a temperatura em Celsius.

Algorithm

Input - Read the variable C


Processing - Convert the value of C using the formula (9*C+160)/5 and assign the value to
variableF
Saída – Apresentar os valores das VariáveisCCelsius eFFahrenheit

Frame Diagram
Temperature_Converter_C_F_Program
Start
LeiaC
F = (9 * C + 160) / 5
Write Celsius and Fahrenheit
Film

Structured Portuguese
Temperature Converter Program C_F
Var
C, F: Integer
Start
LeiaC
F = (9 * C + 160) / 5
Write CCelsius = FFahrenheit
Film

b. Read a temperature in degrees Fahrenheit and present it converted.


in degrees Celsius. The conversion formula is C ← (F - 32) * (5/9), being
F is the temperature in Fahrenheit and C is the temperature in Celsius.

Algorithm

Entrada – Ler a variávelF


Processing - Convert the value by using the formula (F-32)*(5/9) and assign the value to
variableC
Saída – Apresentar os valores das VariáveisFFahrenheit eCCelsius

Frames Diagram
Temperature_Converter_F_C_Program
Start
LeiaF
C = (F - 32) * (5/9)
Write Fahrenheit and Celsius
Film

Structured Portuguese
Temperature Converter Program C_F
Var
F, C:Inteiro
Start
LeiaF
C = (F - 32) * (5/9)
Write Fahrenheit = Celsius
Film

c. Calculate and present the value of the volume of a can of oil, using the
formula VOLUME ← 3.14159 * R ↑ 2 * HEIGHT.

Algorithm

Input – Read the variables ReA


Processing - Calculate the volume using the formula 3.14159*R^2*A and assign the value to
variableV
Output - Present the value of variable V

Frame Diagram
Cylinder Volume Calculation Program
Start
LeiaR, A
V:= 3.14159*R^2*A
WriteV
Film

Structured Portuguese
Cylinder Volume Calculation Program
Var
R, AV:Real
Start
LeiaR
LeiaA
V = 3.14159 * R^2 * A
WriteV
Film

d. Calculate the number of liters of fuel consumed in a


trip, using a car that does 12 km per liter. To obtain the calculation,
the user must provide the time spent and the average speed during the trip.
In this way, it will be possible to obtain the distance traveled with the formula DISTANCE ←
TIME * SPEED. Given the value of the distance, just calculate the amount of
liters of fuel used for the trip with the formula LITROS_USADOS ←
DISTANCE / 12. The program must present the values of the average speed,
time spent on the trip, the distance traveled, and the amount of liters used in the
trip.

Algorithm

Input - Read the variables TIME and AVERAGE_SPEED


Processing - Calculate the distance using the formula TIME * AVERAGE_SPEED
and assign the value to the variable DISTANCE; calculate the amount of gasoline used by the
DISTANCE/12 formula and assign the value to the variable LITERS_USED
Saída – Apresentar os valores das variáveisVELOCIDADE_MEDIA, TEMPO, DISTANCIA
eLITROS_USADOS

Frames Diagram
Fuel Cost Calculation Program
Start
Read TIME and AVERAGE SPEED
DISTANCIA:=TEMPO*VELOCIDADE_MEDIA
LITROS_USADOS:=DISTANCIA/12
EscrevaVELOCIDADE_MEDIA, TEMPO, DISTANCIA, LITROS_USADOS
Film

Structured Portuguese
Fuel Consumption Calculation Program
Var
TEMPO, VELOCIDADE_MEDIA, DISTANCIA, LITROS_USADOS :Real
Start
Read TIME
LeiaVELOCIDADE_MEDIA
DISTANCIA:=TEMPO*VELOCIDADE_MEDIA
LITROS_USADOS:=DISTANCIA/12
AVERAGE_SPEED
Write TIME
Write DISTANCE
Write USED_LITERS
Film

e. Perform the calculation and presentation of the amount of an overdue installment,


using the formula INSTALLMENT ← VALUE + (VALUE * (RATE/100) *
TIME).

Algorithm

Entrada – Ler as variáveisVALOR, TAXAeTEMPO


Processing - Calculate the new value of the installment with the formulaVALUE + (VALUE*
(TAX/100) * TIME) and assign the value to the variable INSTALLMENT
Output - Present the value of the variable INSTALLMENT

Frame Diagram
Installment Calculation Program
Start
READ VALUE, RATE, TIME
INSTALLMENT := VALUE + (VALUE * (RATE / 100) * TIME)
WRITE SERVICE
Film

Structured Portuguese
Payment Calculation Program
Var
VALOR, TAXA, TEMPO, RENDERING: Real
Start
LeiaVALUE
LeiaTAXA
ReadTIME
INSTALLMENT:=AMOUNT+ (AMOUNT * (RATE/100) * TIME)
Write SERVICE
Film

f. Read two values for the variables A and B, and swap their values.
so that variable A takes on the value of variable B and variable B
now take the value of variable A. Present the swapped values.

Algorithm

Input - Read the variables A and B


Processing - Assign the value of variable A to variable C Assign the value of
Variable B to Variable D; Assign the value of D to A and assign the value of C to B
Output - Present the value of the variable AeB

Diagram of Frames
Program_Swap_Values_A_B
Start
Leia A, B
C:=A
D:=B
A:=D
B:=C
WriteAeB
Film

Structured Portuguese
Program_ Exchange_Values_A_B
Var
A, BC, D:Real
Start
ReadA
LeiaB
C:=A
D:=B
A:=D
B:=C
Write A
WriteB
Film

g. Read four numbers and present the result of the addition and multiplication.
based on the use of the distributive property. That is, if
Given the variables A, B, C, and D, they must be added and multiplied by A.
B with A, C with A and D with A. Then B with C, B with D and finally C with D.

Algorithm

Input - Read the variables A, B, CeD.


Processing - sum (A+B) + (A+C) + (A+D) + (B+C) + (B+D) + (C+D) and assign the
value the variableSUM; multiply (A*B) * (A*C) * (A*D) * (B*C) * (B*D) * (C*D) and
assign the value to the variable PRODUCT
Saída – Apresentar os valores das variáveisSOMAePRODUTO

Frame Diagram
Sum_and_Product_Calculation_Program
Start
LeiaA, B, CeD
SOMA:=(A+B) + (A+C) + (A+D) + (B+C) + (B+D) + (C+D)
PRODUTO:=(A*B) * (A*C) * (A*D) * (B*C) * (B*D) * (C*D)
WRITE SUM and PRODUCT
Film

Structured Portuguese
Calculation_Sum_and_Product_Program
Var
A, B, C, D,SUM, PRODUCT: Real
Start
LeiaA
LeiaB
LeiaC
LeiaD
SUM := (A + B) + (A + C) + (A + D) + (B + C) + (B + D) + (C + D)
PRODUCT := (A*B) * (A*C) * (A*D) * (B*C) * (B*D) * (C*D)
Write SUM
WRITE PRODUCT
Film

h. Develop a program that calculates and presents the volume of a box


rectangular through the formula: VOLUME ← LENGTH * WIDTH *
HEIGHT.

Algorithm

Input - Read the variables LENGTH, WIDTH, and HEIGHT.


Processing - Calculate the volume of the rectangular box with the formula LENGTH *
WIDTH * HEIGHT and assign the value to the variable VOLUME
Output - Present the value of the variable VOLUME
Framework Diagram
Volume Calculation Program
Start
LeiaCOMPRIMENTO, LARGURA e ALTURA
VOLUME:= COMPRIMENTO * LARGURA * ALTURA
Write VOLUME
Film

Structured Portuguese
Volume_Calculation_Program
Var
COMPRIMENTO, LARGURA, ALTURA, VOLUME: Real
Start
Read LENGTH
Width
Height
VOLUME:=COMPRIMENTO * LARGURA * ALTURA
WriteVOLUME
Film

Read an integer and present the result of its square.


of this number.

Algorithm

Input - Read the variable N


Processing - Raise to the power of two and assign the value to the variable SQUARE
Saída – Apresentar o valor da variávelQUADRADO

Frames Diagram
Square Calculation Program
Start
LeiaN
QUADRADO:=N^2
WRITE SQUARE
Film

Structured Portuguese
Square Calculation Program
Var
A,SQUARE: Integer
Beginning
LeiaA
SQUARE:=A^2
WriteSQUARE
Film

j. Read two integers (variables A and B) and print the result of the square of
difference of the first value from the second.

Algorithm
Input - Read the variables A and B
Processing - Calculate the difference between VariableA and VariableB and assign the value to
variávelD; elevar a variávelDao quadrado e atribuir o valor a variável
SQUARE_OF_THE_DIFFERENCE
Output - Display the value of the variable SQUARE_OF_DIFFERENCE

Frames Diagram
Difference_Square_Calculation_Program
Start
Read A, B
D=A-B
SQUARE_OF_THE_DIFFERENCE:=D^2
SQUARE_OF_THE_DIFFERENCE
Film

Structured Portuguese (I REDID THIS)


Square_of_difference_program
Var
A, B, R: Integer
Start
LeiaA
LeiaB
R:=(A-B)^2
Write
Film

k. Develop a program that presents the value of the conversion


in reais (R$) of a value read in dollars (US$). The program must request the
value of the dollar exchange rate and also the amount of dollars available with the
user.

Algorithm

Input - Read the variables DOLLAR and QUOTATION


Processing - Calculate the value in reais using the formula DOLLAR*EXCHANGE_RATE and assign it
value to the variable REAL
Output - Present the value of the REAL variable

Frame Diagram
Dollar to Real Conversion Program
Start
ReadDOLLAR, QUOTATION
REAL:=DOLAR*COTAÇÃO
WriteREAL
Film

Structured Portuguese
Dollar_Real_Conversion_Program
Var
DOLAR, COTAÇÃO, REAL:Natural
Start
ReadDOLLAR
Read QUOTE
REAL:=DOLAR*COTAÇÃO
Write REAL
Film

1. Develop a program that performs the display of the conversion value.


in US dollars (US$) from a value read in reais (R$). The program should ask for the value
of the dollar quotation and also the amount of reais available with the
user.

Algorithm

Input - Read the variables REAL and QUOTE


Processing - Calculate the value in reais using the formula REAL*QUOTE and assign it
value to the variable DOLLAR
Saída – Apresentar o valor da variávelDOLAR

Frames Diagram
Real to Dollar Conversion Program
Beginning
LeiaREAL, QUOTATION
DOLAR:=REAL*COTAÇÃO
Write DOLLAR
Film

Structured Portuguese
Real to Dollar Conversion Program
Var
REAL, QUOTATIONDOLLAR: Natural
Start
LeiaREAL
Read QUOTE
DOLAR:=REAL*COTAÇÃO
Write DOLLAR
Film

m. Develop a program that reads three values (A, B, and C) and


present as the final result the sum of the squares of the three values read.

Algorithm

Input - Read the variables A, B, and C


Processing - raise the Variables A, BeCao square, sum the squares assign the
value the variableSUM_OF_SQUARES
Output - Present the value of the variable SUM_OF_SQUARES

Frame Diagram
Sum_of_Squares_Program
Start
LeiaA, BeC
SOMA_DOS_QUADRADOS:=A^2+B^2+C^2
WRITE_SUM_OF_SQUARES
Film

Structured Portuguese
Sum_of_Squares_Program
Var
A, B, CSOMA_DOS_QUADRADOS:Inteiro
Start
LeiaA
LeiaB
LeiaC
SOMA_DOS_QUADRADOS:=A^2+B^2+C^2
WRITE_SUM_OF_SQUARES
Film

n. Develop a program that reads three values (A, B, and C) and


apresente como resultado final o quadrado da soma dos três valores lidos.

Algorithm

Input - Read the variables A, BeC.


Processing - Calculate the sum of the variables A, BeCe and assign the value to the variable SUM;
raise the variable SUM to the square and assign the value to the variable SQUARE_OF_SUM
Output - Present the value of the variable SQUARE_OF_THE_SUM

Frame Diagram
Program_Calculate_Square_of_the_sum
Start
LeiaA, BeC
SOMA:=A+B+C
QUADRADO_DA_SOMA:=SOMA^2
SQUARE_OF_THE_SUM
Film

Structured Portuguese
Program_Calculation_Square_of_the_sum
Var
A, B, C,R:Real
Start
LeiaA
LeiaB
LeiaC
R = (A + B + C)^2
Write
Film

You might also like