+ 1

Whats wrong with my program?

import java.util.Scanner; public class Main { Static double sum; 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 a,double b,double c, double d) { sum = a+b+c+d; double res = sum/4; return res; } }

11th May 2022, 9:01 PM
Exiled Penguin 🐧
Exiled Penguin 🐧 - avatar
2 ответов
+ 1
static double sum; // small s in static
11th May 2022, 9:04 PM
Jayakrishna 🇮🇳
+ 1
Oh, what a stupid mistake😅
11th May 2022, 9:04 PM
Exiled Penguin 🐧
Exiled Penguin 🐧 - avatar