Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class Starter {
- public static void main(String[] args) {
- Random rnd = new Random();
- String[] names = {"Georgi", "Petar", "Stefan", "Ivan", "Mariq"};
- String[] family = {"Georgiev", "Petrov", "Stefanov", "Ivanov", "Marinova"};
- Students[] studentList = new Students[5];
- Scores[] scoreList = new Scores[5];
- //СЪЗДАВАНЕ НА ОБЕКТИТЕ STUDENTS И SCORES
- for (int i = 0; i < 5; i++) {
- studentList[i] = new Students(names[i], family[i], String.valueOf(10000 + rnd.nextInt(20000)));
- double gradeM = 2.00 + (6.00 - 2.00) * rnd.nextDouble(); //произволно число межу 2.00 и 6.00
- double gradeP = 2.00 + (6.00 - 2.00) * rnd.nextDouble();
- double gradePro = 2.00 + (6.00 - 2.00) * rnd.nextDouble();
- scoreList[i] = new Scores(gradeM, gradeP, gradePro);
- }
- //ОТПЕЧАТВАНЕ НА ДАННИТЕ ЗА УЧНИЦИТЕ И ОЦЕНКИТЕ
- for (int j = 0; j < 5; j++) {
- studentList[j].info();
- System.out.printf("Math grade: %.2f \n", scoreList[j].gradeMath);
- System.out.printf("Physics grade:%.2f \n", scoreList[j].gradePhysics);
- System.out.printf("Programming grade: %.2f \n", scoreList[j].gradeProgramming);
- System.out.printf("Avg grade: %.2f \n", scoreList[j].avgGrade());
- System.out.println("---------");
- }
- }
- }
- public class Students {
- //Полета
- String name;
- String family;
- String number;
- //Конструктор
- public Students(String name , String family, String number){
- this.name = name;
- this.family= family;
- this.number = number;
- }
- //Custom method
- public void info(){
- System.out.println("Name: " + name);
- System.out.println("Family name: " + name);
- System.out.println("Number: " + number);
- }
- }
- public class Scores {
- //Полета
- double gradeMath;
- double gradePhysics;
- double gradeProgramming;
- //Конструктор
- public Scores(double gradeMath, double gradePhysics, double gradeProgramming) {
- this.gradeMath = gradeMath;
- this.gradePhysics = gradePhysics;
- this.gradeProgramming = gradeProgramming;
- }
- //Custom method
- public double avgGrade() {
- return (gradeMath + gradePhysics + gradeProgramming) / 3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment