Java arrays beginner problem | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 3

Java arrays beginner problem

Write a program in java that reads in 10 student marks into an array called marks and computes the number of students who have failed (got a mark less than 40). The program should then output this number. https://code.sololearn.com/cZqiBjTJ57NQ/?ref=app This is what I did help me please!

23rd Feb 2021, 1:43 PM
okurpants
okurpants - avatar
22 ответов
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); double[] marks = new double[10]; int count = 0; for (int i = 0; i < marks.length; i++) { // System.out.println("Enter the mark:"); marks[i] = input.nextDouble(); } System.out.println(studentMarks(marks,count)); } private static int studentMarks(double[] marks,int count) { for (int i = 0; i < marks.length; i++) { if (marks[i] < 40) { count += 1; } } return count; } }
23rd Feb 2021, 6:30 PM
Jayakrishna 🇮🇳
+ 3
okurpants Is problem in output? Just take out this statement from loop and add after loop.. System.out.println(studentMarks(marks,count)); If it is practice peoblem then remove output statement from loop of "enter number" , it is not asked to print...
23rd Feb 2021, 3:19 PM
Jayakrishna 🇮🇳
+ 3
okurpants i also mentioned all in my 1st answer. What changes you tried by that..? I told you "take out of loop the last output statement (line no:11) and remove asking enter marks output statement (line no:9) "
23rd Feb 2021, 6:29 PM
Jayakrishna 🇮🇳
+ 2
okurpants did you read my full answer? You may not.. There is no problem in code but you may doing wrong in outputting.. I given answer by guessing what actually you may need. How you want your output there? Mention details... hope it helps..
23rd Feb 2021, 6:18 PM
Jayakrishna 🇮🇳
+ 1
okurpants i already posted edited code . Check out that.
23rd Feb 2021, 6:36 PM
Jayakrishna 🇮🇳
+ 1
Use google translation if you may have any difficulty in understanding language replies.. Edit: okurpants you're welcome...
23rd Feb 2021, 6:54 PM
Jayakrishna 🇮🇳
+ 1
I thought you may having difficulty in understating my replies (in english language), because i told same in all.. Just my suggestion, if i guess right.. else nothing.. edit : okurpants I just guessed. No worries. its ok.
23rd Feb 2021, 7:05 PM
Jayakrishna 🇮🇳
+ 1
👍👍👍
23rd Feb 2021, 7:08 PM
Jayakrishna 🇮🇳
0
https://www.sololearn.com/post/75089/?ref=app Please put this in a code playground and add its link. :)
23rd Feb 2021, 2:07 PM
Matthew
Matthew - avatar
0
Major done
23rd Feb 2021, 2:13 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 did you read the question? There's no problem in my code but it's not doing what I want.
23rd Feb 2021, 4:49 PM
okurpants
okurpants - avatar