3 Replies - 1167 Views - Last Post: 03 August 2012 - 08:59 AM Rate Topic: -----

#1 BlackFiredDragon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 19-July 12

shapes.java:52: error: reached end of file while parsing } ^ 1 error

Posted 03 August 2012 - 08:35 AM

I'm writing a code to represent the area of a few shapes using object and class.... Anyway, this is the error I'm getting:

shapes.java:52: error: reached end of file while parsing
}
^
1 error


Here's my code:

import java.util.Scanner;

class shapes
{
	void shapes()
	{
		System.out.println("Areas of Circle, Rectangle, And Square...");
	}
}
class circle extends shapes
{
	void circle(double a, double B)/>
	{
		System.out.println("Area Of Circle:");
		System.out.println(a*b*B)/>;
	}
class rectangle extends shapes
{
	void rectangle(double a, double B)/>
	{
		System.out.println("Area Of Rectangle:");
		System.out.println(a*B)/>;
	}
class square extends shapes
{
	void square(double a)
	{
		System.out.println("Area Of Square:");
		System.out.println(a*a);
	}
}
class Stuff
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Circle - Enter Diameter...");
		double a = input.nextDouble();
		double b = a / 2;
		circle objc = new circle();
		objc.circle(3.14, B)/>;
		rectangle objr = new rectangle();
		System.out.println("Enter Length And Width Of Rectangle...");
		double c = input.nextDouble();
		double d = input.nextDouble();
		objr.rectangle(c, d);
		square objs = new square();
		System.out.println("Enter Length Of One Side Of Square...");
		double x = input.nextDouble();
		objs.square(x);
	}
}


Thanks for any help

Is This A Good Question/Topic? 0
  • +

Replies To: shapes.java:52: error: reached end of file while parsing } ^ 1 error

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: shapes.java:52: error: reached end of file while parsing } ^ 1 error

Posted 03 August 2012 - 08:41 AM

These "reached end while parsing" errors are almost always due to mismatched/missing close braces. I had to add two close braces to what you posted to match them correctly. And that doesn't mean it's right, it just means you're missing two close braces somewhere. You seem to have an odd mixture of classes and methods that you may need to untangle a bit. Indenting your code properly will help you see the mismatched brace errors more easily.
Was This Post Helpful? 2
  • +
  • -

#3 BlackFiredDragon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 19-July 12

Re: shapes.java:52: error: reached end of file while parsing } ^ 1 error

Posted 03 August 2012 - 08:47 AM

View PostGregBrannon, on 03 August 2012 - 08:41 AM, said:

These "reached end while parsing" errors are almost always due to mismatched/missing close braces. I had to add two close braces to what you posted to match them correctly. And that doesn't mean it's right, it just means you're missing two close braces somewhere. You seem to have an odd mixture of classes and methods that you may need to untangle a bit. Indenting your code properly will help you see the mismatched brace errors more easily.


Oh, thanks about the curly braces thing, that was actually the only problem. It works perfectly now.
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7949
  • View blog
  • Posts: 13,538
  • Joined: 19-March 11

Re: shapes.java:52: error: reached end of file while parsing } ^ 1 error

Posted 03 August 2012 - 08:59 AM

The two missing braces should go at the end of class rectangle and class circle.

You will find it a lot easier if you go ahead and use standard coding conventions wrt capitalization. Class names start with uppercase, method names start with lowercase, both get internal capitalization.


From a class design perspective, you might want to let each Shape determine how to prompt for its dimensions, rather than writing that code in your main. Shape.queryUserForDimensions() or something like that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1