+ 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!
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;
}
}
+ 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...
+ 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) "
+ 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..
+ 1
okurpants i already posted edited code . Check out that.
+ 1
Use google translation if you may have any difficulty in understanding language replies..
Edit:
okurpants you're welcome...
+ 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.
+ 1
👍👍👍
0
https://www.sololearn.com/post/75089/?ref=app
Please put this in a code playground and add its link. :)
0
Major done
0
Jayakrishna🇮🇳 did you read the question? There's no problem in my code but it's not doing what I want.
0
Jayakrishna🇮🇳 I only want the number of failed students to be printed
0
Jayakrishna🇮🇳 can you edit my code and help me out if its possible?
0
I cannot remove it Jayakrishna🇮🇳
0
Jayakrishna🇮🇳 the thing is after each mark is entered the remaining attempts also displays in the screen
0
Jayakrishna🇮🇳 I only want the final value of count which is the number of failed students to be displayed
0
okurpants would you make a little effort by doing your own attempt please? if you doesn't you will never increase your skill ^^
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
0
Jayakrishna🇮🇳 thank you so much it worked
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.