Q1_20251109103341.webp
May76

Q1_20251109103341.webp

  • Media owner May76
  • Ngày thêm
1 of 1
Paper No: 3
Question 1:
(2 marks) Read PE instructions at the bottom of the exam paper.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Write a class named Student with the following information:
- name:String
gpa: double
+Student()
Student
+Student(name: String, gpa: double)
+getPass(): String
+setName(lastname:String)
+toString():String
Where:
The program output might look something like:
Enter name: hoa
Enter gpa: 5.4
1. Test setName()
2. Test getPass()
Enter TC (1 or 2): 1
Enter lastname: nguyen
OUTPUT:
hoa nguyen, 5.4

Student - default constructor.
Student(name: String, gpa: double)- constructor,
which sets values for all attributes.
⚫ getPass(): String- return "pass" if gpa>=5.0
otherwise return "fail".
⚫ setName(lastname:String) - return the name with
the first letter in uppercase.
toString() return String with format name, gpa
Do not format the result.
Enter name: lan
Enter gpa: 4.5
1. Test setName()
2. Test getPass()
Enter TC (1 or 2): 2
OUTPUT:
fail
Zoom
- FUO
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
May76
Ngày thêm
Lượt xem
3,421
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom