Java code에서 묻습니다.

table99의 이미지

public class GradeOutput
{
int e;
int m;

void input_grade(int a, int b){ //(error 가 발생합니다.)
e = a;
m = b;
}

void output_grade(){
Sytem.out.println(e+m);
}
public static void main(String args[])
{
GradeOutput g1,g2;
g1 = new GradeOutput();
g2 = new GradeOutput();
g1.input_grade(90,85);
g2.input_grade(80,80);

g1.output_grade();
g2.output_grade();
}
}

table99의 이미지

-Syntax errors on token "{",{ expected after this token
-Void is an invalid type for the Variable input_grade
-Syntax error on token "void" record expeted

isanghan의 이미지

에러 메시지가 괄호 문제 같아서 이걸로 해결 될지 모르겠지만
일단 C++이나 자바에서 class 내 필드의 수식자를 생략하면
기본 protected 입니다
void 앞에 public을 추가하세요

--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--
N년째 초보입니다

table99의 이미지

class Grade{
int e;
int m;

void input_grade(int a, int b){
e=a;
m=e;
}

void output_grade(){
Sytem.out.println(e+m);
}
}

public class GradeOutput
{
public static void main(String args[])
{
Grade g1,g2;
g1=new Grade();
g2=new Grade();
g1.input_grade(90,85);
g2.input_grade(80,80);

g1.output_grade();
g2.output_grade();
}
}

프로그램을 한 개의 클래스로 구현한 것입니다.
Grade 클래스는 성적 입력을 위한 메소드인 input_grade()와 성적출력을 위한 메소드인 output_grade()메소드를 정의한 클래스입니다.
GradeOutput클래스는 실행을 위해 main() 메소드를 정의한 클래스입니다.
한개의 소스파일로 작성해도 되고 클래스별로 나누어서 두 개의 소스 파일로 작성해도 됩니다. 두 개의 소스 파일로 작성한 경우에는 각각을 컴파일한 다음 main() 메소드가 정의되어 있는 GradeOutput클래스를 실행시키면 됩니다.
프로그램을 한 개의 클래스로 구현한 것입니다. 한개의 클래스로 구현되었으므로 한개의 소스파일로 작성되어야 합니다.

댓글 첨부 파일: 
isanghan의 이미지

일단 스크린샷에 있는 소스를 기준으로
4, 15행에 있는 괄호는 있으면 안됩니다.

--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--
N년째 초보입니다

table99의 이미지

4,15행에 있는 괄호를 지우니 됩니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.