Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help me create a pseudo code to my code and explanation to it import java.util.Scanner; public class Paint1 { public static void

Can someone please help me create a pseudo code to my code and explanation to it

import java.util.Scanner;

public class Paint1 {

public static void main(String[] args) {

// create an object for scanner class Scanner scnr = new Scanner(System.in);

// declare the variables double wallHeight = 0.0;

double wallWidth = 0.0;

double wallArea = 0.0;

double gallonsPaintNeeded = 0.0;

// declare a final variable final double squareFeetPerGallons = 350.0;

// Implement a do-while loop to ensure input is valid do{ // try block try { // Prompt user to input wall's height System.out.println("Enter wall height (feet): "); wallHeight = scnr.nextDouble(); // check if the wallHeight is less than or 0 // then throw an exception if(wallHeight<=0) { // throw an exception throw new Exception(); } } // catch the exception catch(Exception e) { // print the invalid message System.out.println("Invalid input!!"); } }while(wallHeight<=0);

// Implement a do-while loop to ensure input is valid

do{ // try block try { // Prompt user to input wall's width System.out.println("Enter wall width (feet): "); wallWidth = scnr.nextDouble(); // check if the wallWidth is 0 or less // then throw an exception if(wallWidth<=0) { // throw an exception throw new Exception(); } } // catch the exception catch(Exception e) { // print the invalid message System.out.println("Inavlid Input!!"); } }while(wallWidth<=0);

// Calculate and output wall area

wallArea = wallHeight * wallWidth;

// print the wall area System.out.println("Wall area: "+wallArea+" square feet");

// Calculate and output the amount of paint (in gallons) needed to paint the wall

gallonsPaintNeeded = wallArea/squareFeetPerGallons;

// print the output paint needed System.out.println("Paint needed: " + gallonsPaintNeeded + " gallons");

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions