Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Created September 16, 2021 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmagbanua/3edb8158dfba1b75316fc96cc23f9f21 to your computer and use it in GitHub Desktop.
Save arielmagbanua/3edb8158dfba1b75316fc96cc23f9f21 to your computer and use it in GitHub Desktop.
Rectangle

Rectangle

Write a Java program to print the area and perimeter of a rectangle.

Starter Code

public class App {
    public static void main(String[] args) throws Exception {
        // scanner
        Scanner scanner = new Scanner(System.in);

        // get the input length
        
        // get the input width

        // calculate the area

        // calculate the perimeter

        scanner.close();
    }
}

Outputs

height: 8.5
width: 5.5

Area is 5.6 * 8.5 = 47.60
Perimeter is 2 * (5.6 + 8.5) = 28.20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment