Guest User

Untitled

a guest
Dec 3rd, 2019
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package paint;
  2. import java.util.Scanner;
  3.  
  4. public class paint {
  5.  
  6. public static void main(String[] args) {
  7. Scanner scnr = new Scanner(System.in);
  8. double wallHeight = 0.0;
  9. double wallWidth = 0.0;
  10. double wallArea = 0.0;
  11. double gallonsPaintNeeded = 0.0;
  12. int x = 1;
  13.  
  14. final double squareFeetPerGallons = 350.0;
  15.  
  16. // Implement a do-while loop to ensure input is valid
  17. do {
  18. try {
  19. // Prompt user to input wall's height
  20. System.out.println("Enter wall height (feet): ");
  21. wallHeight = scnr.nextDouble();
  22. if (wallHeight > 0) {
  23. x = 2;
  24. }
  25. }
  26. catch(Exception e) {
  27. System.out.println("Please enter a valid number");
  28. wallHeight = scnr.nextDouble();
  29. }
  30. } while(x == 1);
  31. }
RAW Paste Data