0

I don't see Any Mistake but Out Says Class Expected At return code block.

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); System.out.println(avgScore); } //create your method here public static double getAverageScore(double score1 ,double score2 ,double score3 ,double score4) {return double ((score1+score2+score3+score4)/4); } } OUTPUT: Main.java:15: error: '.class' expected public static double getAverageScore(double score1 ,double score2 ,double score3 ,double score4) {return double ((score1+score2+score3+score4)/4); ^ Main.java:15: error: not a statement public static double getAverageScore(double score1 ,double score2 ,double score3 ,double score4) {return double ((score1+score2+score3+score4)/4); ^ Main

26th May 2022, 12:52 PM
We Doru
We Doru - avatar
2 Answers
+ 2
Invalid syntax for casting it is. Use public static double getAverageScore(double score1 ,double score2 ,double score3 ,double score4) { return score1+score2+score3+score4)/4; } // all are double values so no need to cast double. it's already in double value....
26th May 2022, 1:08 PM
Jayakrishna 🇼🇳
0
I hAve used Return within public static double, And there is no void in that block of code. So why error. According to Rule, I Applied.
26th May 2022, 12:59 PM
We Doru
We Doru - avatar