I\'m trying to convert python code to pseudocode.. I have the original problem a
ID: 3734718 • Letter: I
Question
I'm trying to convert python code to pseudocode.. I have the original problem and the the python code below:
rate = []
rate.append([30, 60, 88, 115, 140])
rate.append([26, 52, 70, 96, 120])
rate.append([24, 46, 67, 89, 110])
rate.append([22, 40, 60, 75, 88])
rate.append([20, 35, 50, 66, 84])
print(" DAYS PER WEEK ")
print("Age ",end="")
for j in range (1, 6):
print(j,end=" ")
print()
for i in range(0, len(rate)):
if(i == 4):
print(i, end =" or more ")
else:
print(i, end = " ")
for r in rate[i]:
print(r,end=" ")
print()
age = int(input("Enter Baby's age:"))
days = int(input("Enter number of days baby will attend each week:"))
if(age >= 4):
age = 4
while(days > 5):
days = int(input("Enter number of days baby will attend each week:"))
print("The charges are: "+str(rate[age][days-1]))
The original question:
Building Block Day Care Center charges varying weekly rates depending on the age of the
child and the number of days per week the child attends, as shown in Table 8-5. Develop the
logic for a program that continuously accepts child care data and displays the appropriate
weekly rate.
Days Per Week
Age in Years
1
2
3
4
5
0
30.00
60.00
88.00
115.00
140.00
1
26.00
52.00
70.00
96.00
120.00
2
24.00
46.00
67.00
89.00
110.00
3
22.00
40.00
60.00
75.00
88.00
4 or more
20.00
35.00
50.00
66.00
84.00
Days Per Week
Age in Years
1
2
3
4
5
0
30.00
60.00
88.00
115.00
140.00
1
26.00
52.00
70.00
96.00
120.00
2
24.00
46.00
67.00
89.00
110.00
3
22.00
40.00
60.00
75.00
88.00
4 or more
20.00
35.00
50.00
66.00
84.00
Explanation / Answer
// create an empty list
rate = []
add [30, 60, 88, 115, 140] to rate
add [26, 52, 70, 96, 120] to rate
add [24, 46, 67, 89, 110] to rate
add [22, 40, 60, 75, 88] to rate
add [20, 35, 50, 66, 84]] to rate
print(" DAYS PER WEEK Age ")
for j = 1 to 6
BEGIN
print(j)
END
// loop through the rate list
for i = 1 to length(rate)
BEGIN
if i is equal to 4
BEGIN
print(i + " or more ")
else
BEGIN
(i + " ")
END
print the contents of rate[i] list
END
age = ask the user to enter age
days = ask the user to enter number of days baby will attend each week
if age is greate than equal to 4
BEGIN
set age to 4
END
while days is greater than 5
BEGIN
days = ask the user to enter number of days baby
will attend each week
END
print("The charges are: "+str(rate[age][days-1]))