• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pseudo code if statement  RSS feed

 
Ching Ming
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my question:

Your friend is car shopping and wants either a white car with white interior or a black car that has any interior other than white. Fill in the blank below with an expression you can use to check that a car meets your friend’s criteria.

PROMPT for carColor
READ carColor
PROMPT for interiorColor
READ interiorColor
IF ("insert expression here") THEN PRINT " THIS CAR MEETS THE DESIRED INTERIOR"
ENDIF

I believe that interiorColor goes into the spot of insert expression here. Is that correct?
 
Piet Souris
Rancher
Posts: 1983
67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yes, but what about the car color? Shouldn't that play a role too?
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... additionally, shouldn't there be a reference to white, black, and some way to represent "other than white"?
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that interiorColor goes into the spot of insert expression here. Is that correct?

NO. The expression that goes there is one that tests whether the user's choice of interior and exterior colors meets the requirements given.
Part of it would be
 
That is only part of it; you also have to check if carColor is black, and if carColor is neither black nor white.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!