in this example it prints out Student’s names and credits what users enter from keyboard to the Vector.
but i wanna only print out Vectors which has credits more than 30.
thanks for any help.
public class Main {
public static void main(String[] args) {
Teacher t = new Teacher("Prof. Smith", "F020");
Student s = new Student("Gipsz Jakab", 34);
Vector<Person> pv = new Vector<Person>();
pv.add(t);
pv.add(s);
Scanner sc = new Scanner(System.in);
String name;
int credits;
for (int i=0;i<5;i++){
System.out.print("Name: ");
name = sc.nextLine();
System.out.print("Credits: ");
credits = sc.nextInt();
sc.skip("\n");
pv.add(new Student(name, credits));
}
System.out.println(pv);
System.out.println("The size of the Vector is: " + pv.size());
}
}
Would this work?
instead of: