Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by wilson on 2/25/2014.
- */
- import java.util.Scanner;
- public class GradesDemo {
- public static void main(String[] args) {
- Grades grade = new Grades();
- String name;
- double score = 0;
- boolean invalid = true;
- Scanner keyboard = new Scanner(System.in);
- //One loop iteration for each student
- for (int i = 0; i < 5; i++) {
- invalid = true;
- //Asks for student name, and stores to array
- System.out.println("Student's Name:");
- name = keyboard.nextLine();
- grade.setName(name, i);
- //while loop to check if score entered by user is valid
- while (invalid == true) {
- System.out.println("Student's Score:");
- score = keyboard.nextDouble();
- //Check if score entered was valid. If not, user will be asked again
- if (score >= 0 && score <= 100)
- invalid = false;
- else
- System.out.println("Score is invalid. Must be between 0-100. Try again.");
- }
- grade.setScore(score, i);
- //Calculate grade
- grade.findGrade(i);
- }
- for (int i = 0; i <5; i++) {
- System.out.println(grade.toString(i));
- }
- }
- }
- Student's Name:
- John Doe
- Student's Score:
- 88
- Student's Name:
- Student's Score:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement