JerBear33

Tire Pressure

Nov 24th, 2021 (edited)
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.52 KB | None | 0 0
  1. clc
  2. clear
  3.  
  4. % Filename: Rivera13p1
  5. % Jeremy Rivera
  6. % EGR 120-001
  7. % User inputs the tire pressure of all 4 tires, program calculates
  8. %        individual tire pressures, limitations of pressure, and average pressure in psi
  9.  
  10. % VARIABLE DECLARATION
  11. %     tirepsi1 (real) user input tire pressure in psi for 1st tire
  12. %     tirepsi2 (real) user input tire pressure in psi for 2nd tire
  13. %     tirepsi3 (real) user input tire pressure in psi for 3rd tire
  14. %     tirepsi4 (real) user input tire pressure in psi for 4th tire
  15. %     avgtirepsi (real) user input all tire pressures and gets average pressure in psi
  16.  
  17. tirepsi1=input ('Input your first tire pressure in psi: ');
  18. tirepsi2=input ('Input your second tire pressure in psi: ');
  19. tirepsi3=input ('Input your third tire pressure in psi: ');
  20. tirepsi4=input ('Input your fourth tire pressure in psi: ');
  21. avgtirepsi=(tirepsi1+tirepsi2+tirepsi3+tirepsi4)/4;
  22.  
  23. if (tirepsi1<28)
  24. fprintf('Tire 1 needs more pressure\n');
  25. else
  26. fprintf('Tire 1 pressure is optimal\n');
  27. end
  28. if (tirepsi2<28)
  29. fprintf('Tire 2 needs more pressure\n');
  30. else
  31. fprintf('Tire 2 pressure is optimal\n');
  32. end
  33. if (tirepsi3<28)
  34. fprintf('Tire 3 needs more pressure\n');
  35. else
  36. fprintf('Tire 3 pressure is optimal\n');
  37. end
  38. if (tirepsi4<28)
  39. fprintf('Tire 4 needs more pressure\n');
  40. else
  41. fprintf('Tire 4 pressure is optimal\n');
  42. end
  43. if (avgtirepsi<30)
  44. fprintf('Suggestion to check the pressure & and add to bare minimum of 30 psi\n');
  45. else
  46. fprintf('Your average tire pressure in psi is: %0.3f\n',avgtirepsi);
  47. end
Add Comment
Please, Sign In to add comment