circle - JAVA: 8 errors, need correcting -


i have assignment computer science class. have put need in code, can not figure out how debug it. getting 8 errors, need these fixed without taking out important code.

import java.awt.*; import java.io; import java.lang.object.*; import java.util.scanner; import java.lang.math;  public class circle() {  public double xcor; public double ycor; public double r; public circle() { xcor = 5.0; ycor = 5.0; r = math.pi; }  public static void main(string args[]) {  public circle(double a, double b, double c) {  xcor = a; ycor = b; r = c; }  circle c1 = new circle(); circle c2 = new circle(1.0, 3.0, 2.0);  c1.x = c1.x + c1.r; c2.r = 1.0 + c2.y; c1.r = 2.0;  double n; n = c1.getarea(); system.out.println(“circle1’s area “ + n);  system.out.println(“the area of circle radius 3 is:”); calcareaforthisradius(3); }  public double getarea()  { return math.pi * r * r; }  public static calcareaforthisradius(double radius) { return radius * radius * math.pi;  } } } 

here advice (to new java programmer) how approach problem.

  1. read compilation error messages. try understand saying. doesn't work because compiler errors based on compiler (writer) thinks probably trying do, , easy confuse it.

  2. read own code carefully. silly typos make huge difference.

  3. if compilation error doesn't seem make sense, go lecture handouts / text books / online tutorials , compare syntax using in code syntax in examples1.

    for instance, code says:

        public class circle()  { 

    if @ examples of classes, should notice different between code , examples. round brackets should not there.

  4. correcting errors can understand cause of other (inexplicable) errors disappear. sometime, bad syntax can confuse compiler sufficiently produces phantom errors elsewhere in code.


a couple more hints:

  1. in java important capitalization right. circle , circle different identifiers.

  2. in java, every class should in separate file. (should ...)

  3. in java, constructs must nested, , every { should have matching }.


1 - non-beginner programmer (e.g. 3rd year cs student) advise differently. them advise consulting syntax specification programming language. learn "read" bnf / ebnf / syntax diagrams ... or whatever notation used.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -