Answer the question
In order to leave comments, you need to log in
How to display a message in the console about whether the given student receives a scholarship?
Using Student class how to set data for student (data will be read from keyboard). how to display a message in the console about whether the student receives a scholarship?. And then fill in the data for n students and display the names of the fellows.
This is my code, please help, I don’t understand how to do it, it seems not difficult, but I can’t understand
Please help me solve this problem
public class Student{
private String name;
private int age, nrenroll;
private double [] aver= new double[2];
public Student(){
}
public Student(String name, int age, int nrenroll, double [] aver){
this.name = name;
this.age = age;
this.nrenroll= nrenroll;
this.aver = aver;
}
public String getName() {
return this.name;
}
public int getAge() {
return this.age;
}
public int getNrEnroll() {
return this.nrenroll;
}
public double[] getAver() {
return this.aver;
}
public String setName(String name) {
this.name = name;
}
public int setAge(int age) {
this.age = age;
}
public int setNrenroll(int nrenroll) {
this.nrenroll = nrenroll;
}
public void setAver(double[] aver) {
this.aver = aver;
}
public boolean Scholarship(){
return (aver [0] >= 7 && aver [1] >= 7);
}
public void day(int perioad) {
if (perioad >= 4 && perioad <= 11) {
System.out.println("доброе утро");
} else if (perioad >= 12 && perioad <= 16) {
System.out.println("добрый день");
} else if (perioad >= 17 && perioad <= 21) {
System.out.println("добрый вечер");
} else {
System.out.println("спокойной ночи");
}
}
class Students {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
Scanner in = new Scanner(System.in);
System.out.println("Введите количество студентов: ");
int n = in.nextInt();
System.out.println("Introduceti numele studentului, varsta, nrmatricolei, notele: ");
for (int count = 0; count < n; count++) {
Student student = new Student();
System.out.println("Introduceti detaliile despre stundet" +count);
System.out.println("Numele: ");
student.setName(in.next());
System.out.println("Varsta: ");
student.setAge(in.nextInt());
System.out.println("Nr matricolei: ");
student.setNrenroll(in.nextInt());
System.out.println("Notele: ");
student.setAver(in.nextDouble());;
students.add(student);
}
for (Student student : students) {
if (student.Scholarship()) {
System.out.println("-----------------------");
System.out.println(student.getName());
student.day();
System.out.println("-----------------------");
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question