Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Java program that makes sure that the tire pressures match. The

ID: 3627644 • Letter: W

Question

Write a complete Java program that makes sure that the tire pressures match. The front tires of a car should have the same pressure and same with the rear tires (but not necessarily the same pressure as the front).
Your program should read in the pressure of the four tires and writes a message that says if the pressures are good or not.
Your program should make sure that the input pressures are within the range: 30 – 40, inclusive. If invalid pressures are entered, alert the user and discard the input, and ask again for input. This validation should continue till the user enters valid pressures for all 4 tires.

Explanation / Answer

import java.io.*; public class Test { public static void main(String[] args) throws Exception { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); double fr, fl, br, bl; do { System.out.println("Enter front right tire pressure"); fr=Double.parseDouble(in.readLine()); if(fr40) System.out.println("Invalid pressure! Try again"); } while(fr40); do { System.out.println("Enter front left tire pressure"); fl=Double.parseDouble(in.readLine()); if(fl40) System.out.println("Invalid pressure! Try again"); } while(fl40); do { System.out.println("Enter back right tire pressure"); br=Double.parseDouble(in.readLine()); if(br40) System.out.println("Invalid pressure! Try again"); } while(br40); do { System.out.println("Enter back left tire pressure"); bl=Double.parseDouble(in.readLine()); if(bl40) System.out.println("Invalid pressure! Try again"); } while(bl40); System.out.println(); if(Math.abs(fr-fl)0.00000001) System.out.println("Back tire pressure is uneven."); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote