Okay so here's my code:
Heres the output:/* Paulino Rosado 9/15/2012 Determine the correct action to maintain proper tire pressure */ import java.util.*; public class Ch3PA1 { public static void main(String[]args) { int type, frontright, frontleft, rearright, rearleft; Scanner Keyboard = new Scanner (System.in); System.out.println("Please enter the number that corresponds to the type of hauling you do!"); System.out.println(" 1. Normal "); System.out.println(" 2. Hauling "); System.out.println(" 3. Rugged "); type = Keyboard.nextInt(); switch(type) { case 1: System.out.println("Please enter the current tire pressure of you're front right tire."); frontright = Keyboard.nextInt(); System.out.println("Please enter the current tire pressure of you're front left tire."); frontleft = Keyboard.nextInt(); System.out.println("Please enter the current tire pressure of you're rear right tire."); rearright = Keyboard.nextInt(); System.out.println("Please enter the current tire pressure of you're rear left tire."); rearleft = Keyboard.nextInt(); if(frontright < 33){ frontright = 33 - frontright; System.out.println("Add "+frontright+"psi to the front right tire"); }else if (frontright > 43){ frontright = frontright - 43; System.out.println("Subtract "+frontright+"psi from the front right tire"); }else if(frontright <= 43 && frontright >= 33); System.out.println("You have the correct tire pressure in the front right tire!"); if(frontleft < 33){ frontleft = 33 - frontleft; System.out.println("Add "+frontleft+" psi to the front left tire"); }else if (frontleft > 43){ frontleft = frontleft - 43; System.out.println("Subtract "+frontleft+" psi from the front left tire"); }else if(frontleft <= 43 && frontleft >= 33); System.out.println("You have the correct tire pressure in the front left!"); if(rearright < 33){ rearright = 33 - rearright; System.out.println("Add "+rearright+" psi to the rear right tire"); }else if (rearright > 43){ rearright = rearright - 43; System.out.println("Subtract "+rearright+" psi from the rear right tire"); }else if(rearright <= 43 && rearright >= 33); System.out.println("You have the correct tire pressure in the right rear tire!"); if(rearleft < 33){ rearleft = 33 - rearleft; System.out.println("Add "+rearleft+" psi to the rear left tire"); }else if (rearleft > 43){ rearleft = rearleft - 43; System.out.println("Subtract "+rearleft+" psi from the rear left tire"); }else if(rearleft <= 43 && rearleft >= 33); System.out.println("You have the correct tire pressure in the rear left tire!"); break; case 2: System.out.println("You picked 2"); break; case 3: System.out.println("You picked 3"); } } }
It seems that after it calculates the correct tire, and gives the output, the else if statement picks up that the variable is within the bounds and outputs "You have the correct tire pressure in the tire" again, but I can't figure out how to fix it! thanks!Please enter the number that corresponds to the type of hauling you do! 1. Normal 2. Hauling 3. Rugged 1 Please enter the current tire pressure of you're front right tire. 43 Please enter the current tire pressure of you're front left tire. 29 Please enter the current tire pressure of you're rear right tire. 43 Please enter the current tire pressure of you're rear left tire. 52 Add -10psi to the front right tire Add 4 psi to the front left tire You have the correct tire pressure in the front left! You have the correct tire pressure in the right rear tire! Subtract 9 psi from the rear left tire You have the correct tire pressure in the rear left tire! Press any key to continue . . .