need help to figure out basic java program
i have to write a java program to input 10 student marks,each mark must be checked to see if it is a pass,merit or fail.I can write a program to check 1 mark as follows
int mark;
System.out.println("What mark did you get");
mark=EasyIn.getInt();
if(mark <= 40)
{
System.out.println("You failed");
}
else(mark == 41 <= 59)
{
System.out.println("You passed");
}
else(mark == 60 <= 100)
{
System.out.println("You got a merit");
}
else
{
System.out.println("Invalid mark please re-enter");
}
my question is how do i write the progarm so it will ask for 10 student marks?
i need to use loops or switch statements
Try something like this...
Quote:
Originally Posted by
shane123
i have to write a java program to input 10 student marks,each mark must be checked to see if it is a pass,merit or fail.I can write a program to check 1 mark as follows
Try this -my syntax is not much good but here goes
int numstudents = 0;
while (numstudents <= 10) {
int mark;
System.out.println("What mark did you get");
mark=EasyIn.getInt();
if(mark <= 40)
{
System.out.println("You failed");
}
else(mark == 41 <= 59)
{
System.out.println("You passed");
}
else(mark == 60 <= 100)
{
System.out.println("You got a merit");
}
else
{
System.out.println("Invalid mark please re-enter");
}
}
out.println("Thats all " + numstudents);
my question is how do i write the progarm so it will ask for 10 student marks?
i need to use loops or switch statements
Try this for size