Connecting Tech Pros Worldwide Help | Site Map

how would I represent the following conditions as a boolean expression in C++

Newbie
 
Join Date: Nov 2009
Posts: 2
#1: 2 Weeks Ago
user must select one of the following: P, S, Q?

down payment is 15% of the total cost

Temperature is at most 70 degrees

truck class cannot be R

**also can someone explain it to me as well?? thank you!!
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 828
#2: 2 Weeks Ago

re: how would I represent the following conditions as a boolean expression in C++


This is not a complete statement of the problem.
Never mind.
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 828
#3: 2 Weeks Ago

re: how would I represent the following conditions as a boolean expression in C++


Are P, S, and Q the three paragraphs that follow?
down payment ...
temperature ...
truck class ...
Needs Regular Fix
 
Join Date: Jul 2008
Posts: 380
#4: 2 Weeks Ago

re: how would I represent the following conditions as a boolean expression in C++


I don't like the one with downpayment. Although you can write something like
(dp == totalcost*0.15) ,
it will lead to comparison of a double(right) and double that was cast to double from integer, if dp was integer. It's not a good idea to compare doubles for equality. It's ok as a homework answer, but not in real life. Or you can write it using integers and using integer arithmetic
dp == totalcost*15/100,
Newbie
 
Join Date: Nov 2009
Posts: 2
#5: 2 Weeks Ago

re: how would I represent the following conditions as a boolean expression in C++


I'm sorry, no, they are three separate problems. My confusion is the examples given by our professor show like this:
condition: Payment must be at least 250.00 dollars
solution: min_payment >= 250.00
I get that and I understand the signs but for some reason I'm having a mental block and just can't seem to get started with this.
Reply