Re: So you think you can dance. Java OOP exercise. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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; } }

7th Feb 2022, 2:49 AM
Chris
Chris - avatar
3 Answers
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; } }
7th Feb 2022, 3:13 AM
L.M.Paredes
L.M.Paredes - avatar
7th Feb 2022, 7:41 AM
Edilson Zau
Edilson Zau - avatar
0
Thanks. It worked!
7th Feb 2022, 11:06 PM
Chris
Chris - avatar