0
Re: So you think you can dance. Java OOP exercise.
Could anyone tell me where I went wrong here? I'd really appreciate it. Thanks! import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); double score1 = read.nextDouble(); double score2 = read.nextDouble(); double score3 = read.nextDouble(); double score4 = read.nextDouble(); double avgScore = getAverageScore(score1, score2, score3, score4); getAverageScore(); } //create your method here public static double getAverageScore(score1, score2, score3, score4) { double avgScore = (score1+score2+score3+score4)/4; return avgScore; } }
3 Antworten
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
double score1 = read.nextDouble();
double score2 = read.nextDouble();
double score3 = read.nextDouble();
double score4 = read.nextDouble();
double avgScore = getAverageScore(score1, score2, score3, score4);//you are just storing the return value of your function
// getAverageScore();the function needs parameters getAverageScore(score1, score2, score3, score4);
System.out.println(avgScore); // you need to print like this or System.out.println(getAverageScore(score1, score2, score3, score4));
}
//create your method here
public static double getAverageScore(double score1, double score2, double score3, double score4) { //you need to declare the type of value it receives in this case double
double avgScore = (score1+score2+score3+score4)/4;
return avgScore;
}
}
0
Thanks. It worked!