Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple exercise

 
Logan Knecht
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing exercise 4 on this site and just wanted some input.

http://chortle.ccsu.edu/CS151/Notes/chap14/progExercises14.html



How would I make it so that the pressure out of range if statement is a method?

Also would



work both ways for each tire so when that runs if either tire is + or - 3 psi it would detect it, or would I have to do it for the leftFront as well?

Any help is appreciated!

Thanks.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Logan Knecht:
How would I make it so that the pressure out of range if statement is a method?

Also would



work both ways for each tire so when that runs if either tire is + or - 3 psi it would detect it, or would I have to do it for the leftFront as well?
1: Replace it with a statement like printPressureOK(frontLeft == frontRight); or similar.
2: Have a private static void printPressureOK(boolean pressureOK) method. Or something similar.
3: Not quite sure what you mean about the + or - but have you tried the Math.abs method?

Good luck with it
 
cheng jian
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
1: Replace it with a statement like printPressureOK(frontLeft == frontRight); or similar.
2: Have a private static void printPressureOK(boolean pressureOK) method. Or something similar.
3: Not quite sure what you mean about the + or - but have you tried the Math.abs method?

Good luck with it


I agree with that!
Make a method to print.
good luck!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somebody agrees with me!! Welcome to JavaRanch, Cheng Jian.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic