I need help, college student, identifier problem

Joined
Mar 7, 2010
Messages
1
Reaction score
0
This program should work fine, but for some reason im getting a identifier expected error for
System.out.println("The area of your room is" + area.);
That line...... Please tell me what im doing wrong, this is due by midnight.


import java.util.Scanner;
public class Area
{
public static void main(String[] args)
{
System.out.println("This program will figure the area of a room.");
displayArea();
System.out.println("The calculation of the area is complete.");
}

/**
The displayArea method displays the area.
*/

public static void displayArea()
{
int length; //length of room
int width; //width of room
int area; //Area of room

//Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner (System.in);

System.out.println("What is the Length of your room?");
length = keyboard.nextInt();

//Validate the input
while (length < 1)
{
//Prompt the user to enter a correct value.
System.out.println("The length must be at least 1.");
System.out.print("Enter the Length of your room");
length = keyboard.nextInt();
}

System.out.println("What is the Width of your room?");
width = keyboard.nextInt();

//Validate the input
while (width < 1)
{
//Prompt the user to enter a correct value.
System.out.println("The width must be at least 1.");
System.out.print("Enter the width of your room");
width = keyboard.nextInt();
}
//Find the area.
{
area= length * width;
}

//Display the area
{
System.out.println("The area of your room is" + area.);


}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top