Skip to content

Instantly share code, notes, and snippets.

@lbattaglioli2000
Created September 14, 2019 16:07
Show Gist options
  • Save lbattaglioli2000/11d9b5544d731a9f9553897c5b021cbb to your computer and use it in GitHub Desktop.
Save lbattaglioli2000/11d9b5544d731a9f9553897c5b021cbb to your computer and use it in GitHub Desktop.
Room.java assignment
public class Room {
/**
* Luigi Battaglioli
* Exercise Room3d
*
* A program that initializes the length, width, and height of a room.
* Then, taking the floor of the room, it will then calculate the room's
* area and perimeter. Then, taking the room as a rectangular solid or
* rectangular prism, it will calculate the room’s surface area and volume.
*
* @param args
*
*/
public static void main(String[] args)
{
/*
* You know – length is 8.52, width is 4.1, and height is 8.1.
*
* You will calculate - area, perimeter, surface area, and volume.
*/
double length = 8.52;
double width = 4.1;
double height = 8.1;
double area = length * width;
System.out.printf("\n\nThe area is: %.4f\n", area);
double perimeter = (2 * length) + (2 * width);
System.out.printf("The perimeter is: %.4f\n", perimeter);
double surfaceArea = 2 * ((width * length) + (height * length) + (height * width));
System.out.printf("The surface area is: %.4f\n", surfaceArea);
double volume = width * length * height;
System.out.printf("The volume is: %.4f\n\n", volume);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment