Asked by dave
Project 1: Student Eligibility Checker
Build a small program that determines if a student qualifies for a field trip discount based on:
Grade level (9–12 only)
Attendance percentage (>= 90)
Parent/guardian consent (Yes/No)
Paid fee status (Yes/No)
Output: One of "Eligible", "Eligible with conditions", or "Not eligible".
Use comparison operators and logical combinations (and/or) to handle all situations.
All Answers 1
Answered by
GPT-5 mini
AI
Here's a simple Python program that implements the rules you described. Rules used:
- Grade must be 9–12.
- Attendance must be >= 90.
- If grade and attendance pass:
- If both parent consent and fee paid are Yes -> "Eligible".
- If either consent or fee (or both) are No -> "Eligible with conditions".
- If grade or attendance fail -> "Not eligible".
Code:
```python
def get_yes_no(prompt):
while True:
ans = input(prompt).strip().lower()
if ans in ('yes', 'y'):
return True
if ans in ('no', 'n'):
return False
print("Please answer Yes or No.")
def main():
try:
grade = int(input("Enter grade level (9-12): ").strip())
except ValueError:
print("Invalid grade. Not eligible.")
return
try:
attendance = float(input("Enter attendance percentage (e.g. 92.5): ").strip())
except ValueError:
print("Invalid attendance. Not eligible.")
return
consent = get_yes_no("Parent/guardian consent (Yes/No): ")
paid = get_yes_no("Paid fee status (Yes/No): ")
# Check basic eligibility by grade and attendance
if not (9 <= grade <= 12) or attendance < 90:
print("Not eligible")
return
# If grade and attendance are OK, decide based on consent and payment
if consent and paid:
print("Eligible")
else:
print("Eligible with conditions")
if __name__ == "__main__":
main()
```
Example scenarios:
- Grade 10, attendance 95, consent Yes, paid Yes -> Eligible
- Grade 11, attendance 92, consent No, paid Yes -> Eligible with conditions
- Grade 8, attendance 98, consent Yes, paid Yes -> Not eligible (grade)
- Grade 12, attendance 88, consent Yes, paid Yes -> Not eligible (attendance)
- Grade must be 9–12.
- Attendance must be >= 90.
- If grade and attendance pass:
- If both parent consent and fee paid are Yes -> "Eligible".
- If either consent or fee (or both) are No -> "Eligible with conditions".
- If grade or attendance fail -> "Not eligible".
Code:
```python
def get_yes_no(prompt):
while True:
ans = input(prompt).strip().lower()
if ans in ('yes', 'y'):
return True
if ans in ('no', 'n'):
return False
print("Please answer Yes or No.")
def main():
try:
grade = int(input("Enter grade level (9-12): ").strip())
except ValueError:
print("Invalid grade. Not eligible.")
return
try:
attendance = float(input("Enter attendance percentage (e.g. 92.5): ").strip())
except ValueError:
print("Invalid attendance. Not eligible.")
return
consent = get_yes_no("Parent/guardian consent (Yes/No): ")
paid = get_yes_no("Paid fee status (Yes/No): ")
# Check basic eligibility by grade and attendance
if not (9 <= grade <= 12) or attendance < 90:
print("Not eligible")
return
# If grade and attendance are OK, decide based on consent and payment
if consent and paid:
print("Eligible")
else:
print("Eligible with conditions")
if __name__ == "__main__":
main()
```
Example scenarios:
- Grade 10, attendance 95, consent Yes, paid Yes -> Eligible
- Grade 11, attendance 92, consent No, paid Yes -> Eligible with conditions
- Grade 8, attendance 98, consent Yes, paid Yes -> Not eligible (grade)
- Grade 12, attendance 88, consent Yes, paid Yes -> Not eligible (attendance)
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.