0% found this document useful (0 votes)
20 views27 pages

Digital Programming Exercises Overview

This document presents 6 digital programming exercises with their respective logics, pseudocodes, variable tables, and flowcharts. The exercises include algorithms to calculate the age of the older brother, the total to be paid for shirts with discounts, the calculation of final grades, and the calculation of salaries and discounts for purchases according to different criteria.

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)
20 views27 pages

Digital Programming Exercises Overview

This document presents 6 digital programming exercises with their respective logics, pseudocodes, variable tables, and flowcharts. The exercises include algorithms to calculate the age of the older brother, the total to be paid for shirts with discounts, the calculation of final grades, and the calculation of salaries and discounts for purchases according to different criteria.

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

DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°1: Develop an algorithm that asks for the age of two siblings and shows a
mensaje indicando la edad del mayor y cuantos años de diferenciatene con el menor.

PROGRAMMING LOGIC

Input variables E1, E2


Variables de salida DE
IF (E1>E2)→DE=E1-E2→'THE FIRST BROTHER HAS', E1, 'AND IS OLDER
FOR', 'YEARS'
THE SECOND BROTHER HAS E2 AND IS OLDER BY
OF, 'YEARS'

2. PSEUDOCODE

1) Start
Print 'AGE OF THE FIRST BROTHER'
3) Read E1
Print 'AGE OF THE SECOND BROTHER'
5) Read E2
If E1>E2
So
Make DE←E1-E2
Read 'THE FIRST BROTHER HAS', E1, 'AND IS OLDER BY'
FROM 'YEARS'

NO

Make DE←E2-E1
Read 'THE SECOND BROTHER HAS', E2, 'AND IS OLDER BY'
OF, 'YEARS'
Fin

3. TABLE OF VARIABLES

NAME DESCRIPTION TYPE


E1 First brother Natural number (IN)

E2 Second brother Natural number (IN)

DE Age difference Natural number (IN)

4. FLOWCHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEERING PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°2: Create an algorithm that calculates the total to pay for the purchase of shirts, if
If you buy three shirts or more, a 20% discount is applied to the total purchase.
less than three shirts a 10% discount.

PROGRAMMING LOGIC

Input variables CAM, PRE


Intermediate variables TOCOM
Output variables TOPAG
Total purchase = n t-shirts * price
If (t-shirts >= 3) → total to pay = total purchase - (total purchase * 0.20)
If not → total to pay = total purchase - (total purchase * 0.10)

2. PSEUDOCODE

1) Start
Print 'NUMBER OF T-SHIRTS TO BUY'
3) Read CAM
PRINT 'T-SHIRT PRICE'
5) Read PRE
Make TOCOM←CAM*PRE
If CAM >= 3
So
Make TOPAG← TOCOM-(TOCOM*0.20)

YES NO

Make TOPAG← TOCOM-(TOCOM*0.10)


8) Read 'TOTAL TO PAY IS', TOPAG
Fin

3. TABLE OF VARIABLES

NAME DESCRIPTION TYPE

CAM N° T-shirts Natural number (IN)

PRE Price of t-shirts Natural number (IN)

TOCOM Total purchase Natural number (IN)

TOPAG Total a pagar Natural number (IN)

4. FLOWCHART

Civil Engineering PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


PROGRAMACION DIGITAL NINA ESCOBAR CINDY 2016 - II

EXERCISE N°3: Develop an algorithm in which the user enters their age and the
It will respond, how many years will objects be used for input and output.

PROGRAMMING LOGIC:

Incoming variable: AGE


Variable of interest: 'AGE'

2. PSEUDOCODE:

1) Start
Print: 'Program to find the age'
Print: 'Enter your age and press continue'
READ: AGE
Print: 'Your age is', age, ' years '
6) End

3. TABLE OF VARIABLES:

NAME DESCRIPTION TYPE

AGE First number to enter Real

Note: Only enter positive numbers.

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

4. FLOWCHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°4: Develop the algorithm that displays the value of two grades, that of the first exam
what is worth 40% and the partial 2 that is worth 60% of the final grade. If the final grade is greater than or equal to
2.96 the student passes and if it is lower the student fails, after telling us this he must
show the final grade.

PROGRAMMING LOGIC:

Variable entrante: Nota 1, Nota 2


Outstanding variable: AVERAGE >= 2.96

2. PSEUDOCODE:

1) Start
PRINT: 'PROGRAM TO FIND THE FINAL GRADE'
PRINT: 'ENTER THE GRADE OF THE FIRST MIDTERM'
4) Read: Note 1
PRINT: 'ENTER THE GRADE FOR THE SECOND EXAM'
6) Read: Note 2
7) Do:
PARTIAL 1 = GRADE1 * 0.40
PARTIAL2 = GRADE2 * 0.60
PROMEDIO FINAL= PARCIAL1+PARCIAL2
8) Assign decision to compare:
Condition: AVERAGE >= 2.96
We are sorry, you failed the subject with a
NOTE, AVERAGE
Print: 'CONGRATULATIONS YOU PASSED THE SUBJECT WITH A
NOTE OF', AVERAGE
PRINT: 'GOOD LUCK'
10) End

3. TABLE OF VARIABLES:

NAME DESCRIPTION TYPE

Note 1 First number to enter Real

Note 2 Second note to enter Real

FINAL AVERAGE Total average of the grades Real


entered

4. FLOWCHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°5: Calculate the amount a person pays for their purchase, taking into account
that the store gives a 15% discount if your purchase exceeds $200,000, otherwise only you will
give a 5% discount.

PROGRAMMING LOGIC:

Variable entrante: 'INGRESAR VALOR DE LA COMPRA'


Outstanding variable: 'PAID DISCOUNT VALUE'

2. PSEUDOCODE:

1) Start
PRINT: 'PROGRAM TO CALCULATE PAYMENT WITH DISCOUNT'
ENTER PURCHASE VALUE
4) Read: VC (purchase sales) Assign decision to compare:
Condition: VC>200
IF IT IS NOT To Do: (DISCOUNT1) D = VC * 0.05
IF YES Do: (DISCOUNT2) D = VC * 0.15
5) Make: (AMOUNT TO PAY) VP = VC - D
6) Print: (amount to be paid) VP
7) End

3. TABLE OF VARIABLES:

NAME DESCRIPTION TYPE

VC Enter the value of the Real


purchase to see sitenes at
a discount access.

Price obtained with a


VP discount depending on Real
amount of your purchase.

4. FLOW CHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°6: Calculate the salary of an employee who is paid per day worked s/30.
Considering that if he/she is over 50 years old, a subsidy of 10% is granted on what he/she earns,
who is discounted 3.5%

PROGRAMMING LOGIC:

Variable entrante: EDAD (ED)


Outstanding variable: FINAL SALARY (SF)

2. PSEUDOCODE:

1) Start
PRINT: 'PROGRAM TO KNOW AN EMPLOYEE'S SALARY
ACCORDING TO AGE
PRINT: 'ENTER AGE'
4) Read: AGE (ED)
5) Make: EARNED SALARY (SG)=30
6) Assign decision:
Condition: ED>50
If it is YES DO: SF = (SG * 0.10) + SG
If it is not TO DO: SF = SG - (SG * 0.0350)
Print: FINAL SALARY (FS)
Fin

3. TABLE OF VARIABLES:

NAME DESCRIPTION TYPE

ED Enter the age to know Real


how much should receive as
payment.

SF Total payment made to Real


user that includes
discounts.

4. FLOWCHART

CIVIL ENGINEERING PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°7: Determine the hypotenuse of a right triangle given the


lengths of its two legs. Develop the corresponding algorithm.

PROGRAMMING LOGIC:

Incoming variable: CAT A, CAT B


Output variable: HYPOTENUSE

2. PSEUDOCODE:

1) Start
PRINT: 'PROGRAM TO FIND THE HYPOTENUSE OF A TRIANGLE'
PRINT: 'ENTER FIRST CATETO'
4) Read: CAT A
PRINT: 'ENTER SECOND CATHETUS'
6) Read: CAT B
7) To do: HIP= SQRT((CATA)^2+(CATB)^2)
PRINT: 'THE HYPOTENUSE IS' HIP
9) End

3. TABLE OF VARIABLES:

NAME DESCRIPTION TIPO

CATA Enter first number Real

CATB Enter second number Real

HIP Result of the sum of the Real


squares of the root

4. FLOWCHART

CIVIL ENGINEERING PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°8: Program to calculate the distance between two coordinate points

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

PROGRAMMING LOGIC

Input Variable X1, X2, Y1, Y2


Variable de Salida D

2. PSEUDOCODE

1) Start
PRINT "ENTER THE COORDINATE OF THE FIRST POINT X1, Y1"
3) Read X1, Y1
PRINT 'ENTER THE COORDINATES OF THE SECOND POINT X2, Y2'
Read X2, Y2
6) Make X=X2-X1
7) Make Y=Y2-Y1
8) Make D=SQRT(X^2+Y^2)
Print 'The distance between the two points is ', D
10) End

3. TABLE OF VARIABLES

NAME DESCRIPTION TYPE

X1 Coordinate of the first Real


point in X

X2 Coordinate of the second Real


point in X

Y1 Coordinate of the first Real


point Y

Y2 Coordinate of the second Real


point in Y

4. FLOW CHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°9: Program for solving quadratic equationstcas.

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

1. PROGRAMMING LOGIC

Input Variable a, b, c
Output Variable d, X1, X2

2. PSEUDOCODE

1) Start
Print 'ENTER THE VALUE OF a'
3) Read a
PRINT 'ENTER THE VALUE OF b'
5) Read b
PRINT 'ENTER THE VALUE OF c'
7) Read c
8) To do d = b^2 - 4 * a * c
9) If d >= 0

So
Make x1 = (-b - SQRT(b^2 - 4*a*c)) / 2*a

X2= (-b+SQRT(b^2-4*a*c)) / 2*a

Print 'THE SOLUTION X1 IS , X1

PRINT 'THE SOLUTION X2 IS X2

If not

PRINT "SOLUTION WITH IMAGINARY ROOTS"

10) End

3. TABLE OF VARIABLES

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

NAME DESCRIPTION TYPE

a First variable of the Real


quadratic equation

b Second variable of the Real


quadratic equation

c Third variable of the Real


quadratic equation

d The discriminant Real

x1 First solution of the Real


quadratic equation

x2 Second solution of the Real


quadratic equation

4. FLOWCHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE N°10: Create an algorithm that calculates the odd numbers that exist between
two numbers.

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

PROGRAMMING LOGIC
Input variables A, B
2. PSEUDOCODE

Start
Print 'Program to determine the odd numbers that are between two numbers

Print 'Enter first digit'
4) Read A
Print 'Enter second digit'
Read B
7) For i = A+1 to B-1
If i mod 2 = 1
So then
Print i
If not
End For
Fin

3. TABLE OF VARIABLES

NAME DESCRIPCION TYPE

A First digit Natural number (IN)

B Second digit Natural number (IN)

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

EXERCISE No. 11: Create an algorithm that calculates the amount to be paid for the service
parking, taking into account that for the first hour of stay there is a
rate of 1000 soles and the remaining ones of 600 soles. Set as data: entry time,
Departure time, started one hour counts as total time.
[Link] LOGIC
Input variables HE,HS
Intermediate HT variables
Output variables TOPAG

[Link]
1) Start
Print 'Program to determine the parking service payment'
Print 'Enter the hours in 24Hr format'
Print 'Enter the check-in time'
5) Read HE
Print 'Enter the departure time'
Reading HS
8) Make HT←HS-HE
If HT > 1
So then
Make TOPAG← (HT -1)*600+1000
Yes No
Make TOPAG←1000

10) Print 'TOTAL TO PAY IS ', TOPAG


Fin
3. TABLE OF VARIABLES

NAME DESCRIPTION TYPE

HE Entry time Natural number (IN)

HS Departure time Natural number (IN)

HT Total time Natural number (IN)

TOPAG Natural number (IN)


Total to pay

CIVIL ENGINEER PRACTICE I - B September 28, 2016


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

Civil Engineer PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

PROPOSED EXERCISE: Create a flow diagram in DFD that stores the names.
and the ages of the group members, calculate the average age and show all the
data.

PROGRAMMING LOGIC:

Variable entrante: N1, EDAD1; N2, EDAD2; N3, EDAD3; N4, EDA4.
Outstanding variable: AVERAGE AGE (AA)

2. PSEUDOCODE:

1) Start
2) To do: N1= ''
Print: 'ENTER GROUP MEMBERS'
Read: N1
Print: 'THE NAME OF THE FIRST MEMBER IS' , N1
PRINT: 'ENTER THE FIRST AGE'
7) Read: AGE1
8) Do: N2= ' '
ENTER NAME OF THE SECOND MEMBER
10) Read: N2
11) Print: 'THE NAME OF THE SECOND MEMBER IS' ,N2
PRINT: 'ENTER THE SECOND AGE'
13) Read: AGE2
14) Do: N3= ''
PRINT: 'ENTER THE NAME OF THE THIRD MEMBER'
16) Read: N3
Print: 'THE NAME OF THE THIRD MEMBER IS' ,N3
Print: 'ENTER THE ELDERLY AGE'
19) Read: AGE3
20) Hacer: N4= ' '
Print: 'ENTER NAME OF THE FOURTH MEMBER'
22) Read: N4
Print: 'THE NAME OF THE FOURTH MEMBER IS' ,N4
Print: 'ENTER THE FOURTH AGE'
25) End

3. TABLE OF VARIABLES:

Civil Engineer PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

NAME DESCRIPTION TYPE

N1 Enter the first name Strim


of the group.
AGE1 Enter the first age of the Enter
group.
N2 Enter the second name Stream
of the group.
AGE2 Enter the second age of the Entero
group.
N3 Enter the third name of the Strim
group.
AGE3 Enter the senior age of Enter
group.
N4 Enter the fourth name Stream
of the group.
AGE4 Enter the fourth age of Entero
group.
AVERAGE AGE Final average of the four Enter
ages.

4. FLOWCHART

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16


DIGITAL PROGRAMMING NINA ESCOBAR CINDY 2016 - II

CIVIL ENGINEER PRACTICE I - B 28-09-16

You might also like