Digital Programming Exercises Overview
Digital Programming Exercises Overview
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
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
4. FLOWCHART
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
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
3. TABLE OF VARIABLES
4. FLOWCHART
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:
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:
4. FLOWCHART
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:
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:
4. FLOWCHART
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:
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:
4. FLOW CHART
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:
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:
4. FLOWCHART
PROGRAMMING LOGIC:
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:
4. FLOWCHART
EXERCISE N°8: Program to calculate the distance between two coordinate points
PROGRAMMING LOGIC
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
4. FLOW CHART
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
If not
10) End
3. TABLE OF VARIABLES
4. FLOWCHART
EXERCISE N°10: Create an algorithm that calculates the odd numbers that exist between
two numbers.
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
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
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:
4. FLOWCHART