Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- A program that prompts for the height and width of a rectangle
- and prints the area of that rectangle.
- All variables should be of type double.
- */
- public class RectArea2
- {
- public static void main (String[] args)
- {
- Scanner in = new Scanner(System.in);
- // Display prompt for rectangle width
- System.out.print("Please enter the width of the rectangle: ");
- // Read width of rectangle
- double width = in.nextDouble();
- // Display prompt for rectangle height
- System.out.print("Please enter the height of the rectangle: ");
- // Read height of rectangle
- double height = in.nextDouble();
- // Compute and print result
- double area = width * height;
- System.out.println(area);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement