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!
2/23/2021 1:43:30 PM
okurpants
22 Answers
New Answerimport 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; } }
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...
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) "
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..
Use google translation if you may have any difficulty in understanding language replies.. Edit: okurpants you're welcome...
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.
https://www.sololearn.com/post/75089/?ref=app Please put this in a code playground and add its link. :)
Jayakrishna🇮🇳 did you read the question? There's no problem in my code but it's not doing what I want.
Jayakrishna🇮🇳 the thing is after each mark is entered the remaining attempts also displays in the screen
Jayakrishna🇮🇳 I only want the final value of count which is the number of failed students to be displayed
okurpants would you make a little effort by doing your own attempt please? if you doesn't you will never increase your skill ^^
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
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.