<identifier> expected area = Not good for new programmer


Joined
Mar 1, 2011
Messages
1
Reaction score
0
/**
* @(#)circle.java
*
*
* @author
* @version 1.00 2011/2/28
*/

import java.util.Scanner;
import java.text.*;

public class circle
{
/** Main Method */
public static void main(String[] args)
{
// Define Constants
final double PI = 3.14159;
final String AREA_FORMAT = "#,##.000";
final String RADIUS_FORMAT = "#.##";

// Define Variables
double radius;
double area;
char rerun;
Scanner input = new Scanner(System.in);
DecimalFormat dfArea = new DecimalFormat(AREA_FORMAT);
DecimalFormat dfRadius = new DecimalFormat(RADIUS_FORMAT);

do
{
// Get data (radius)
System.out.print("Enter the radius of the circle: ");
radius = input.nextDouble();
// Inovke isDataValid method
if (isDataValid(radius))
{
// Invoke computeArea method
computeArea(radius);

// Invoke printArea method
printArea(radius, area);
}

// invoke computeAgain() method
} while (computeAgain());
}

// methods
public static void printArea(area, area)
{
// Display results
// Using a combination of DecimalFormat Class and printf formatters
System.out.printf("The area of a cirlce is computed by the following formula:\n\tArea = Radius x Radius x PI (%.5f)", PI);
System.out.println("\nBy subtituting in the value(s) that you entered, the formula looks like:");
System.out.printf("\tArea = %s x %s x PI (%.5f)", dfRadius.format(radius), dfRadius.format(radius), PI);
System.out.printf("\n\tArea = %s\n", dfArea.format(area));
}

public static double computeArea(radius, PI)
{
System.out.print("Enter the radius of the circle: ");
radius = input.nextDouble();
area = radius * radius * PI;
}

public static boolean isDataValid(radius)
{
if (radius <= 0)
{
System.out.printf("The area of a circle can only be calculated by using a radius value greater than 0.\nYou entered \"%s\" for the radius.\n", dfRadius.format(radius));
}
}

public static boolean computeAgain()
{
do
{
//Ask user if they want to enter new numbers
System.out.print("Would you like to rerun(Y/N)?: ");
rerun = false;
//Run switch to find users answer
switch (rerun)
{
case 'Y':System.out.println("Goodluck!");
break;
case 'y':System.out.println("Goodluck!");
break;
case 'N':System.out.println("Goodbye!");
break;
case 'n':System.out.println("Goodbye!");
break;
default:System.out.println("You may only enter Y or N!");
break;
}
}while(rerun());
}

}




<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected
<identifier> expected

I receive this error 4 times. Help/explanation would be greatly appreciated!!
 
Ad

Advertisements


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

Top