Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CLASS STARTER
- package Tema4;
- public class Starter {
- public static void main(String[] args) {
- Utilities.Input();
- Utilities.Processing_1();
- Utilities.Output();
- }
- }
- //CLASS UTILITIES
- package Tema4;
- import java.util.Scanner;
- public class Utilities{
- private static Students student1;
- private static Students student2;
- private static Students student3;
- private static Students student4;
- private static Students student5;
- public static void Input(){
- Scanner scan = new Scanner(System.in);
- double mat;
- double physics;
- double programing;
- //Entering marks
- System.out.println("Моля въведете оценка по математика: ");
- mat = scan.nextDouble();
- System.out.println("Моля въведете оценка по физика: ");
- physics = scan.nextDouble();
- System.out.println("Моля въведете оценка по програмиране: ");
- programing = scan.nextDouble();
- student1.Marks.enterMarks(mat, physics, programing);
- student2.Marks.enterMarks(mat, physics, programing);
- student3.Marks.enterMarks(mat, physics, programing);
- student4.Marks.enterMarks(mat, physics, programing);
- student5.Marks.enterMarks(mat, physics, programing);
- }
- public static void Processing_1(){
- //Creating 5 students
- Students student1 = new Students("Velizar", "Angelov", 18406);
- Students student2 = new Students("Boqn", "Gyurov", 18404);
- Students student3 = new Students("Georgi", "Georgiev", 18409);
- Students student4 = new Students("Tsvetelin", "Goranov", 18426);
- Students student5 = new Students("Viktor", "Valentinov", 18307);
- student1.printInfo();
- student2.printInfo();
- student3.printInfo();
- student4.printInfo();
- student5.printInfo();
- }
- public static void Output(){
- //Printing info
- student1.printInfo();
- student2.printInfo();
- student3.printInfo();
- student4.printInfo();
- student5.printInfo();
- }
- }
- //CLASS STUDENTS
- package Tema4;
- public class Students {
- //Fields
- public String name;
- public String family;
- public int number;
- public Tema4.Marks Marks;
- //Constructor with parameters
- public Students(String name, String family, int number){
- this.name = name;
- this.family = family;
- this.number = number;
- }
- public Students(){
- this.name = " ";
- this.family = " ";
- this.number = 0;
- }
- //Method to print
- public void printInfo(){
- System.out.println("Име: " + this.name);
- System.out.println("Фамилия: " + this.family);
- System.out.println("Курсов номер: " + this.number);
- System.out.println("Оценка по математика: " + this.Marks.mathemathicsMark);
- System.out.println("Оценка по физика: " + this.Marks.physicsMark);
- System.out.println("Оценка по програмиране: " + this.Marks.programingMark);
- System.out.println("Среден успех: " + Marks.averageGrade(this.Marks.mathemathicsMark, this.Marks.physicsMark, this.Marks.programingMark));
- }
- }
- //CLASS MARKS
- package Tema4;
- public class Marks {
- //Fields
- public double mathemathicsMark;
- public double physicsMark;
- public double programingMark;
- //Constructors
- public Marks(){
- this.mathemathicsMark = 2.0;
- this.physicsMark = 2.0;
- this.programingMark = 2.0;
- }
- //Method to enter marks
- public void enterMarks(double mathemathicsMark, double physicsMark, double programingMark){
- this.mathemathicsMark = mathemathicsMark;
- this.physicsMark = physicsMark;
- this.programingMark = programingMark;
- }
- //Method to find average grade
- public double averageGrade(double mathemathicsMark, double physicsMark, double programingMark){
- double avg;
- avg = (mathemathicsMark + physicsMark + programingMark) / 3;
- return avg;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement