JAVA PROGRAMMING
Task: Write a Java class that declares variables to represent the length
and width of a room in feet. Assign appropriate values to the variables —
for example, length = 15 and width = 25. Compute and display the floor
space of the room in square feet (area = length * width). Display
explanatory text with the value—for example, The floor space is 375
square feet. Save the class as Room.java
Output:
Source code:
public class Room
{
public static void main(String[] args)
{
int length = 20;
int width = 30;
int area = length * width;
System.out.println("The floor space is " + area + " square feet.");
}
}
Task: Write a Java class that declares variables to represent the length
and width of a room in feet. Assign appropriate values to the variables —
for example, length = 15 and width = 25. Compute and display the floor
space of the room in square feet (area = length * width). Display
explanatory text with the value—for example, The floor space is 375
square feet. Save the class as Room.java
Output:
Source code:
public class Room
{
public static void main(String[] args)
{
int length = 20;
int width = 30;
int area = length * width;
System.out.println("The floor space is " + area + " square feet.");
}
}