Java arrays beginner problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answers
+ 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
0
Jayakrishna🇮🇳 I only want the number of failed students to be printed
23rd Feb 2021, 6:26 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 can you edit my code and help me out if its possible?
23rd Feb 2021, 6:27 PM
okurpants
okurpants - avatar
0
I cannot remove it Jayakrishna🇮🇳
23rd Feb 2021, 6:31 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 the thing is after each mark is entered the remaining attempts also displays in the screen
23rd Feb 2021, 6:32 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 I only want the final value of count which is the number of failed students to be displayed
23rd Feb 2021, 6:33 PM
okurpants
okurpants - avatar
0
okurpants would you make a little effort by doing your own attempt please? if you doesn't you will never increase your skill ^^
23rd Feb 2021, 6:35 PM
visph
visph - avatar
0
visph i did all of this with my own skills by the way i just want help if you cant help me stop making a scene
23rd Feb 2021, 6:36 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 thank you so much it worked
23rd Feb 2021, 6:39 PM
okurpants
okurpants - avatar
0
Jayakrishna🇮🇳 trust me I tried putting that part out of the loop but i got what I have described above. But then since you kept telling that its working i deleted the whole thing in intellij and copy pasted your edited code. And then i tried to find what you have edited in my code and got to know that you've done the same too(just putting that part out of the loop). I think my intellij is not working properly or something. Im sorry if I made you uncomfortable or something.
23rd Feb 2021, 7:03 PM
okurpants
okurpants - avatar