I have to wrtie a valid C++ condition (Boolean expression) for each of the following checks: (naming my own variable when needed)

if the value of the variable GPA is between 3.0 and 3.6 excluding 3.0 and 3.6. 
if a voter is at least 18 years old and had registered to vote. 
if a car traveled more than 55 miles per hour, ran a red light, or park illegally. 
if a character is an alphabetical letter (upper or lower cases).

This is what I have so far does is look right so far? If not tell how to fix it


if the value of the variable GPA is between 3.0 and 3.6 excluding 3.0 and 3.6.

if( Gpa >= 3.0)&&(Gpa==3.6)

if a voter is at least 18 years old and had registered to vote.

if (Voter == 18)

         return vote;

if a car traveled more than 55 miles per hour, ran a red light, or park illegally.
if a character is an alphabetical letter (upper or lower cases).

Recommended Answers

All 11 Replies

>>if( Gpa >= 3.0)&&(Gpa==3.6)
Re-read the requirement and you will figure out what is wrong. if( GPA > 3.0 && GPA < 3.6) The voter one is wrong too, but I'm not going to just give you the answer. Hint: there is no return statement required.

The statement about the car: you will need three variables: int speed, bool ranredlight, and bool parked. Then test those variables as required by the statement.

The last one is probably the most difficult for you to do because you have to check if the character is between 'a' and 'z' or between 'A' and 'Z'.

Ok how about this?

if the value of the variable GPA is between 3.0 and 3.6 excluding 3.0 and 3.6.

if(GPA >3.0 && GPA < 3.6)

if a voter is at least 18 years old and had registered to vote.

if(voter >=18 && voter=registered)

if a car traveled more than 55 miles per hour, ran a red light, or park illegally.

if( car >> 55 && car=red ll car= parkill)

if a character is an alphabetical letter (upper or lower cases).

if( character = alphaup ll character = alphalow)

does it look right?

if(voter >=18 && voter=registered) if(voter >=18 && voter=registered) use == logical operator instead of the assignment operator =. Do the same in all the other problems too.

Car: replace ll with ||, they are not the same.

The last one isn't even close.

also, look up >> and see what it means.

How about this

if the value of the variable GPA is between 3.0 and 3.6 excluding 3.0 and 3.6.

if(GPA >3.0 && GPA < 3.6)

if a voter is at least 18 years old and had registered to vote.

if(voter >==18 && voter==registered)

if a car traveled more than 55 miles per hour, ran a red light, or park illegally.

if( car > 55 && car==red || car== parkill)

if a character is an alphabetical letter (upper or lower cases).

if( character = alphaup ll character = alphalow)

The last one im stump on does anyone have a solution?

anyone home :)

ups

This isn't an IIRC, and no one here is going to respond very well to demands for help. You are very much closer. What you need to do now is two things.

Take a look at the available C++ operators and use the correct ones. (The GPA problem is fine, but the others need help.)
C++ Operators

The other thing you need to do is review some logic tables.
Logical Conjunction

OK, three. Fix that ll to use || like AD instructed you.

Do those things and you'll fix your problems easily.

Hope this helps.

that 11 is a typo but other than that I don't see why im going wrong. can you be little more detailed

that 11 is a typo but other than that I don't see why im going wrong. can you be little more detailed

if(voter >==18 && voter==registered) Look closely at this -- there is no such operator as >== Study the operators in the link you were previously given.

If you are ever going to be successful programmer you must pay great attention to detail. One small slipup can cause hours of headaches.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.