저는 Java에 비교적 익숙하지 않아이 프로그램을 만들기로 결정했습니다. 메서드로 게임하는 법을 배우기 시작하기에 충분한 작업 이었기 때문입니다. 어쨌든 이것은 바로 지금 내 프로그램입니다. .'.class'라는 오류 메시지가 나타납니다.
import javax.swing.JOptionPane;
public class smallAverage{
public smallAverage getsmall() {
String sd1 = JOptionPane.showInputDialog("What is the first number?");
double sdx = Double.parseDouble (sd1);
String sd2 = JOptionPane.showInputDialog("What is the second number?");
double sdy = Double.parseDouble (sd2);
String sd3 = JOptionPane.showInputDialog("What is the third number?");
double sdz = Double.parseDouble (sd3);
return double sdx;
return double sdy;
return double sdz;
}
public smallAverage getavg() {
String ad1 = JOptionPane.showInputDialog("What is the first number");
double adx = Double.parseDouble (ad1);
String ad2 = JOptionPane.showInputDialog("What is the second number");
double ady = Double.parseDouble (ad2);
String ad3 = JOptionPane.showInputDialog("What is the third number");
double adz = Double.parseDouble (ad3);
return double adx;
return double ady;
return double adz;
}
public smallAverage work() {
double small = Math.min(sdx, sdy, sdz);
double avg = (adx + ady + adz)/3;
System.out.println("The smallest of "+ sdx+ sdy+ sdz+ " is " + small + ", and the average of"+ adx+ ady+ adz+ " is "+ avg+ ".");
}
}
여기에 무슨 실제 수학은 정말 코드가 내가 배우고 싶은 것을 작동의 방법, 나에게 아무 의미도 없습니다. 여러 가지 방법으로이 코드를 다시 작성하려고 시도했지만 올바른 것으로 가장 가깝습니다. 왜 작동하지 않을지 전혀 모르겠습니다. 내가 터미널을 통해 컴파일 할 때 나는이 얻을 :
smallAverage.java:12: error: '.class' expected
return double sdx;
^
smallAverage.java:13: error: '.class' expected
return double sdy;
^
smallAverage.java:14: error: '.class' expected
return double sdz;
^
smallAverage.java:27: error: '.class' expected
return double adx;
^
smallAverage.java:28: error: '.class' expected
return double ady;
^
smallAverage.java:29: error: '.class' expected
return double adz;
^
6 errors
크게 당신이 돌아 오면 더 이상 지정자를 입력 할 필요가 없습니다
smallAverage 객체를 반환하도록 정의 된 메서드를 비롯한 여러 가지 방법으로 코드가 잘못되었습니다. 방법을 만드는 방법에 대한 장을 다시 읽으십시오. –