Conditional Algorithms
Conditional Algorithms
David Padilla
Level: 2 Parallel: B
04/03/2018
Subject: Programming 1
Employees of a store will be given a seniority bonus. If they have one year, they
they will give $100; if they are 2 years old, $200, and so on up to 5 years old. For those who
if they have more than 5, the bonus will be $1000. Create an algorithm and represent it through
flowchart and pseudocode to determine the bonus to be received by a
worker.
Algorithm Problem2
Define antiquity as Integer;
Enter the employee's years of service...
Read antiquity;
If antiquity = 0 Then
The employee will receive $0 in bonus.
FinSi
If antiquity = 1 Then
The employee will receive a $100 bonus.
FinSi
If antiquity = 2 Then
The employee will receive a $200 bonus.
FinSi
If seniority = 3 Then
The employee will receive a $300 bonus.
FinSi
If antiquity = 4 Then
The employee will receive a $400 bonus.
FinSi
If seniority = 5 Then
The employee will receive a $500 bonus.
FinSi
If seniority > 5 Then
The employee will receive a $1000 bonus.
FinSi
FinAlgorithm
2. Create an algorithm that allows determining the weekly salary of a worker based on
in the hours worked and the pay per hour, considering that from the hour number
41 to 45, each hour is paid double, from hour 46 to 50, triple, and to work
more than 50 hours is not allowed. Represent the algorithm with a flowchart
and the pseudocode.
Algorithm Problem3
Define hours as integer;
Define payment as Integer;
Define salary as Integer;
Enter the number of hours worked..
Read hours;
Enter the amount paid for the hours worked...
Read payment;
If hours >= 41 & hours <= 45 Then
salary <- ((hours-41)*(pay*2))+(41*pay);
Write 'Your weekly salary for the hours you worked is:', salary, 'usd';
FinSi
If hours >= 46 & hours <= 50 Then
salary <- ((hours - 46) * (pay * 3)) + (46 * pay);
Write 'Your weekly salary for the hours you worked is:', salary, 'usd';
FinSi
If hours > 50 Then
It is not allowed to work more than 50 hours a week...
FinSi
If hours < 41 Then
salary
Write 'Your weekly salary for the hours you worked is:', salary, 'usd';
FinSi
FinAlgorithm
3. The students of a school wish to take a study trip, but they require
determine how much the ticket will cost, considering that the bus fares are
Following: if there are more than 100 students, the cost is $20; if there are between 50 and 100, $35;
between 20 and 49, $40, and if they are less than 20 students, $70 for each one. Create the algorithm
to determine the cost of the ticket for each student. Represent the algorithm using the
flowchart and the pseudocode
Algorithm Problem4
Define students as Integer;
Define total as Real;
Define each_passage as Integer;
Enter the number of students who will be taking the trip...
Read students;
total <- 0;
cada_pasaje <- 0;
If students > 100 Then
total <- (total+20)*students;
each_passage <- each_passage + 20;
FinSi
If students >= 50 & students <= 100 Then
total <- (total+35)*students;
each_passage <- each_passage + 35;
FinSi
If students >= 20 & students < 49 Then
total <- (total+40)*students;
each_passage <- each_passage + 40;
FinSi
If students <20 Then
total <- (total+70)*students;
each_passage <- each_passage + 70;
FinSi
The cost of the ticket for each student will be:
The total cost of the trip will be:
FinAlgorithm
4. Create an algorithm that, based on a provided grade (0-10), indicates with
The corresponding grades are: 10 is 'A', 9 is 'B', 8 is 'C', 7 and 6 are 'D', and 5
A 0 is 'F'. Represent the flowchart and the pseudocode.
Algorithm Problem5
Define calif as Integer;
Enter your rating..
Read caliph;
If calif<0 Then
There is no such thing
FinSi
If calif > 10 Then
Write 'Does not exist'.
FinSi
If calif=10 Then
Write 'A';
FinSi
If calif=9 Then
Write 'B';
FinSi
If calif=8 Then
Write 'C';
FinIf
If calif=7 Then
Write 'D';
FinSi
If calif=6 Then
Write 'E';
FinSi
If calif <= 5 Then
Write 'F';
FinSi
If calif >= 0 Then
Write 'F';
FinSi
FinAlgorithm
5. Create an algorithm that, based on a provided number (1-7), indicates the day of the week.
the week that corresponds to it (M-S). Represent the flowchart and the pseudocode.
Algorithm Problem6
Define number as Integer;
Write 'Enter a number from 1 to 7...';
Read number;
If number=1 Then
The number corresponds to the day Monday.
FinSi
If number=2 Then
The number corresponds to Tuesday.
FinSi
If number=3 Then
The number corresponds to Wednesday.
FinSi
If number=4 Then
The number corresponds to Thursday.
FinSi
If number=5 Then
The number corresponds to the day Friday.
FinSi
If number=6 Then
The number corresponds to Saturday.
FinSi
If number=7 Then
The number corresponds to the day Sunday.
FinSi
If number <= 0 Then
The number does not correspond to any day of the week.
FinSi
If number > 7 Then
The number does not correspond to any day of the week.
FinSi
FinAlgorithm
The Secretary of Education has decided to grant a performance bonus to all the
teachers based on the following score:
Points Prize
0–100 1 salary
101–150 2 minimum wages
151 and onwards 3 minimum wages
Create an algorithm that determines the amount of bonus a teacher will receive.
(must capture the value of the minimum wage and the teacher's points). Represent it
algorithm through the flowchart, and the pseudocode.
Algorithm Problem7
Define points As Integer;
Define salary as Integer;
Enter the points obtained by the teacher...
Read points;
salario <- 386;
If points >= 0 & points <= 100 Then
salary <- salary * 1;
You earn a bonus of: salary;
FinSi
If points >= 101 & points <= 150 Then
salary <- salary*2;
You earn a bonus of:
FinSi
If points >= 151 Then
salary <- salary*3;
You earn a bonus of: salary;
FinSi
FinAlgorithm
7. Create an algorithm and represent it using a flowchart and pseudocode that
allow to determine which package a person can buy with the money that
you will receive in December, considering the following:
Package A. If you receive $50,000 or more, a television, a modular, and three pairs will be purchased.
of shoes, five shirts and five pants.
Package B. If you receive less than $50,000 but more (or equal to) $20,000, it will be purchased.
a recorder, three pairs of shoes, five shirts, and five pants.
Package C. If you receive less than $20,000 but more (or equal) to $10,000, two will be purchased.
pairs of shoes, three shirts, and three pants.
Package D. If you receive less than $10,000, you will have to settle for a couple of
shoes, two shirts and two pants.
Algorithm Problem8
Define amount as Real;
Enter the amount of money you received...
Read amount;
If amount >= 50000 Then
The person will buy package A: a television, a modular, three
pairs of shoes, five shirts, and five pants;
FinSi
If amount < 50000 & amount >= 20000 Then
The person will buy package B: a recorder, three pairs of shoes,
five shirts and five pants
FinSi
If amount < 20000 & amount >= 10000 Then
The person will buy package C: two pairs of shoes, three shirts and
three pants
FinSi
If I mount <10000 Then
The person will buy package D: a pair of shoes, two shirts, and two.
pants
FinSi
FinAlgorithm
8. Create an algorithm and represent it using a flowchart and pseudocode that
allow to determine the amount of the Christmas bonus that an employee will receive from a
store, considering that if its seniority is more than four years or its salary is less than
of two thousand pesos, he will correspond to 25% of his salary, and otherwise he will only
It will correspond to 20% of this.
Algorithm Problem9
Define antiquity as an integer;
Define salary as real;
Define bond as Real;
Enter the years of service ..
Read antiquity;
Enter the salary amount ..
Read salary;
bonus <- 0;
If seniority > 4 | salary < 2000 Then
bonus <- salary * 0.25;
SiNo
bonus <- salary * 0.20;
FinSi
Write 'Your bonus will be: ', bonus, 'usd';
FinAlgorithm
9. The health secretary requires a flowchart that represents the algorithm that
allow to determine which type of vaccine (A, B, or C) should be administered to a person,
considering that if you are over 70 years old, regardless of sex, type C is applied; if
is between 16 and 69 years old, and is a woman, B is applied, and if he is a man, A; if he is younger than
16 years old, type A is applied, regardless of gender.
Algorithm Problem10
Define age as Integer;
Define sex as Integer;
Enter the patient's age...
Read age;
Write 'Enter the patient's sex: man=1 and woman=2...';
Read sex;
If age > 70 Then
The patient will be given the type C vaccine.
Finish
If age >= 16 && sex=2 Then
The patient will be given the type B vaccine.
FinSi
If age <= 69 && gender = 2 Then
The patient will be given the type B vaccine.
FinSi
If age >= 16 && sex=1 Then
The patient will receive the type A vaccine.
FinSi
If age <= 69 && sex = 1 Then
The patient will be given the type A vaccine.
FinSi
If age < 16 Then
The patient will receive the type A vaccine.
FinSi
FinAlgorithm
10. The bank 'Stuffed Bandit' wants to calculate the current balance for one of its clients,
minimum payment and the payment to avoid generating interest. The known data are: balance
client's front, amount of the purchases made and the payment deposited in the cutoff
previous. To calculate the minimum payment, 15% of the current balance must be considered, and to not
generate interest corresponds to 85% of the current balance, considering that this balance must
include 12% of the interest caused by not making the minimum payment and $200 for the fine for
the same reason. Implement the corresponding algorithm and represent it through the
flowchart and pseudocode.
Algorithm Problem12
Define previous_balance As Real;
Define purchase_amount as Real;
Define current_balance as Real;
Define minimum_payment as Real;
Define no_interests as Real;
Write 'previous balance:';
Read previous_balance;
Write 'amount purchases:';
Read purchase_amount;
Write 'Deposit payment:';
Read saldo_actual;
current_balance <- (previous_balance - purchase_amount);
Write 'The current balance is:', current_balance;
minimum_payment <- (current_balance*0.15);
Write 'minimum_payment =', minimum_payment;
(current_balance * 0.85 + (current_balance * 0.85) * 0.12 + 200);
Write 'You are not interested =', no_interests;
FinAlgorithm