Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Main
- {
- public static void main( String[] args ) {
- String[] surnames = { "Mitchell", "Ortiz", "Luu", "Zimmerman", "Brooks" };
- Double[] grades = new Double [5];
- Random rand = new Random();
- for (int i = 0; i < grades.length; i++) {
- Double min = 0.0;
- Double max = 100.0;
- double x = (Math.random() * ((max - min) + 1)) + min;
- double xrounded = Math.round(x * 100.0) / 100.0;
- grades[i] = xrounded;
- }
- Integer[] studentID = { 12345, 23456, 34567, 45678, 56789 };
- System.out.print("Values:\n\t");
- for (int i = 0; i < grades.length; i++) {
- System.out.print(surnames[i] + " " + grades[i] + " " + studentID[i] + "\n\t");
- }
- int found = 0;
- while (found == 0) {
- System.out.println();
- Scanner keyboard = new Scanner(System.in);
- System.out.print("ID number to find: ");
- int idFind = keyboard.nextInt();
- for (int i = 0; i < studentID.length; i++) {
- if (studentID[i] == idFind) {
- System.out.println("\nFound in slot " + i);
- System.out.println("\tName : " + surnames[i]);
- System.out.println("\tAverage: " + grades[i]);
- System.out.println("\tID: " + studentID[i]);
- found = found + 1;
- }
- }
- System.out.println();
- if (found == 0) {
- System.out.println("Student ID number not found.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement