ex 5 Students from ex. Objects and Classes
Здравейте, имам следният въпрос, трябва да разделя данните на първо име, второ име и оценка, но понеже оценката ми е тип Double не знам как да направя split. Прилагам част от кода:
List <Students> infoStudents = new ArrayList(); for (int i = 0; i < n; i++) { String [] tokens = scanner.nextLine().split(".\\s+"); String firstName = tokens [0]; String secondName = tokens [1]; double grade = Double.parseDouble(tokens [2]);
Това е пълния код.
https://pastebin.com/WH4fbXqL
Благодаря предварително!
-
Students
Write a program that receives n count of students and orders them by grade (in descending). Each student should have first name (string), last name (string) and grade (floating-point number).
Input
-
First line will be a number n
-
Next n lines you will get a student info in the format "{first name} {second name} {grade}"
Output
-
Print each student in the following format "{first name} {second name}: {grade}"
Example
Input |
Output |
4 Lakia Eason 3.90 Prince Messing 5.49 Akiko Segers 4.85 Rocco Erben 6.00 |
Rocco Erben: 6.00 Prince Messing: 5.49 Akiko Segers: 4.85 Lakia Eason: 3.90 |