Intro to JAVA please see below: In order to paint a wall that has a number of wi
ID: 3906642 • Letter: I
Question
Intro to JAVA please see below:
In order to paint a wall that has a number of windows, we want to know its area. Each window has a size of 2 ft by 3 ft. Write a program that reads the width and height of the wall and the number of windows, using the prompts
Wall width:
Wall height:
Number of windows:
Then print the area.
CODE:
// Import the Scanner class
public class WallArea
{
public static void main(String[] args)
{
// Declare a scanner
// Prompt for and read the width and height
// and the number of windows
// Compute the area of the wall without the windows
System.out.println("Area: " + area);
}
}
Explanation / Answer
Java program:
// Import the Scanner class
import java.util.Scanner;
//class Starts
public class WallArea
{
public static void main(String[] args)
{
// Declare a scanner
Scanner in = new Scanner(System.in);
// Prompt for and read the width and height
System.out.print("Wall width:");
double width=in.nextDouble();
System.out.print("Wall height:");
double height=in.nextDouble();
// and the number of windows
System.out.print("Number of windows:");
int windows=in.nextInt();
// Compute the area of the wall without the windows
double area=width*height;
System.out.println("Area: " + area);
}
}
//class end
Output:
Wall width:15
Wall height:12
Number of windows:2
Area: 180.0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.