There are 2000 students in a course. They wrote a mathematics test which was scored out of 40 and then converted to percentage.
1. Draw a flowchart that reads the name, sex and score of each student, and outputs the names of the female students that scored below 45% and how many they are.
2. Write a pseudocode program that reads the name, sex and score of each student, and outputs the names of the female students that scored below 45% and how many they are.
For the code, something like
count=0
for i=1..2000
with student[i] do {
read name,sex,score
pct = score*5/2
sub45 = false
if pct < 45 then
if sex = "F" then
count++
print name
}
}
}
print "There were ",count," females scoring below 45%"
1. Flowchart for finding female students with scores below 45%:
[START] -> [Initialize count of female students below 45% to zero]
-> [Read name, sex, and score of a student]
-> [Check if the student is female]
-> [Check if the score is below 45%]
-> [If both conditions are true, output the name of the student]
-> [Increment count of female students below 45% by one]
-> [Repeat the above steps for all students]
-> [Output the count of female students below 45%]
-> [END]
2. Pseudocode for finding female students with scores below 45%:
```
Set count of female students below 45% to zero
For each student in the course:
Read name, sex, and score of the student
If sex is female and score is below 45%:
Output the name of the student
Increment count of female students below 45% by one
Output the count of female students below 45%
```
Explanation:
To solve this problem, we need to iterate over each student in the course, read their name, sex, and score, and then check if they are female and have a score below 45%. If these conditions are met, we output the name of the student and increment the count of female students below 45%. Finally, we output the count of female students below 45%.
The flowchart visually represents the steps involved in the process, while the pseudocode provides a structured and detailed representation of the solution logic.