1 import javax.swing.JOptionPane; 2 import java.util.Scanner; 3 4 class Main 5 { 6 7 public class RoomDimension() 8 { 9 double length; 10 double width; 11 12 public double getArea() 13 { 14 return length * width; 15 } 16 17 } 18 19 20 21 public static void main(String[] args) { 22 //System.out.println("Hello world!"); 23 } 24 25 26 }
Added by Alexander D.
Close
Step 1
The compiler says: Main.java:7: error: '{' expected public class RoomDimension() ^ This tells you the error is at the line declaring RoomDimension — the compiler found '(' where it expected a '{'. Show more…
Show all steps
Your feedback will help us improve your experience
Crystal Wang and 71 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Text: Write a program in Java, including comments and a screenshot of the output. Thank you. Description: Write a program to compute the area and perimeter of a rectangle. The program will input the length and width of the rectangle from the user. It will compute the area and perimeter by calling static methods written for this purpose. Finally, it will display the length, width, area, and perimeter. Do this assignment using procedural programming. Implementation: Create a project named RectangleProc. In the above project, create a class named RectangleProc containing the main method. Within the above class, additionally write the following two methods: - A static method named computeArea with two input parameters: double len and double wid. It will compute the area of the rectangle using the values of length and width passed and, on exit, will return the area to the caller as a double. - A static method named computePerim with two input parameters: double len and double wid. It will compute the perimeter of the rectangle using the values of length and width passed and, on exit, will return the perimeter to the caller as a double. In the main method of the above class, do the following: - Input length and width values from the user. - Call the static method computeArea and pass it the length and width, and receive the area in return. - Call the static method computePerim and pass it the length and width, and receive the perimeter in return. - Use a single String variable to store the entire output of the program. Store the output in the output variable using a series of string concatenations. The output will contain the length, width, area, and perimeter. - Display the content of the output variable in a single message dialog box. Method Headers: Here are the proposed method headers for computeArea and computePerim: public static double computeArea(double len, double wid) public static double computePerim(double len, double wid) Test Data: Test Input: Test the program for the following length and width values: 30, 20 Test Output: For the above test input, the output should look as follows: Length: 30 Width: 20 Area: 600 Perimeter: 100
Akash M.
Write a static method called larger that accepts two double parameters and returns the larger of the two values. If the values are equal, it doesn't matter which one is returned. JAVA
Christian O.
Assume the existence of a Window class with integer instance variables width, height, xPos, and yPos. Define the method toString for the Window class. The String representation of a Window object should be of the form "A 'width'x'height' window at ('xPos','yPos')" where the values within the '''s are replaced by the actual values of the corresponding instance variables. For example, given a Window object whose width is 80, height is 20, xPos is 0, and yPos is 30, toString should return "A 80x20 window at (0,30)".
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD