Question

Suppose your program has the following declarations to represent information about a student: string major //...

Suppose your program has the following declarations to represent information about a student:

string major // possibly empty

float gpa ;

bool female//true if female false if male

Write C++ logical conditions corresponding to each of the following sets. Your answers should be as compact as possible and cover all cases.

  1. Male students, whose major starts with the letter 'e' (economics, english, etc), and whose GPA is 2.0 or lower
  2. All students, whose major ends in the letter 's' (mathematics, physics, etc), and whos GPA is a perfect 4.0.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

below are your conditions

a) !female && !major.empty() && major.find('e') == 0 && gpa <= 2.0

b) !major.empty() && major.find('s') == major.length() -1 && gpa= 4.0

Add a comment
Know the answer?
Add Answer to:
Suppose your program has the following declarations to represent information about a student: string major //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT