jeudi 26 mars 2015

Display the top two grades between students



I am taking a CSC class for java. This example has me stuck and honestly I cannot figure out what is wrong with my code even with the debugger. My question is specifically:




  1. How do I get my prompt to display and read multiple inputs only using Loops like Do-while, While, For. I am not allowed to use Arrays.




  2. Is my logic wrong?




Here is my code:



package assignment16;
import java.util.Scanner;

public class Exercise59 {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.print("Enter number of Students ");
int numberOfStudents = input.nextInt();

System.out.print("Enter students name");
String name1 = input.nextLine();

System.out.print("Enter student's grade");
double grade1 = input.nextDouble();


for (int i = 0; i < numberOfStudents; i++){

}


}

}



Aucun commentaire:

Enregistrer un commentaire