0% found this document useful (0 votes)
32 views2 pages

Lab 3 Kien Truc Basic

The document describes coding exercises for several classes: 1. A Book class with attributes like author, title, number of pages, and whether it is fiction. It instructs to code the class and test it. 2. A Student class with attributes like name, ID, birthdate, address, major, and GPA. It instructs to code accessors, a print method, and test it by instantiating objects. 3. A Rectangle class with width and height attributes and methods to input data, display data, calculate area, and calculate perimeter. It instructs to test the Rectangle class. 4. A program to manage fractions with arithmetic operations like addition, subtraction, multiplication and division

Uploaded by

Hoàng Anh Chung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Lab 3 Kien Truc Basic

The document describes coding exercises for several classes: 1. A Book class with attributes like author, title, number of pages, and whether it is fiction. It instructs to code the class and test it. 2. A Student class with attributes like name, ID, birthdate, address, major, and GPA. It instructs to code accessors, a print method, and test it by instantiating objects. 3. A Rectangle class with width and height attributes and methods to input data, display data, calculate area, and calculate perimeter. It instructs to test the Rectangle class. 4. A program to manage fractions with arithmetic operations like addition, subtraction, multiplication and division

Uploaded by

Hoàng Anh Chung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Given a class Book defined as having the following attributes:


Author author;
String title;
int noOfPages;
boolean fiction;
Actually code and compile the Book class based on the attributes and “get”/“set” methods
called. Write a main program to test all the above operations.
2. Given a class Student defined as having the following attributes:
String name;
String studentId;
Date birthDate;
String address;
String major;
double gpa;
Actually code and compile the Student classes as follows:
• Include accessor methods for every attribute.
• Reflect the appropriate accessibility on all features.
• Include one or more constructors for class.
• Write a method with the header public void printAllAttributes() that can be used to
display the values of all attributes to the command prompt, for example:
Student Name: John Smith
Student ID: 123-45-6789
etc.
Then, modify the accompanying Main class’s main method to take advantage of your new constructors
to instantiate one of each of the object types.
Additional proposed exercises:
3.

1
Write a Rectangle class to represent rectangles, with two data fields (width, height) and four methods
(input data, display data, calculate and return area, calculate and return perimeter). Write another class
to test all methods of the Rectangle class.
4.
Write java program to manage fractions with addition, subtraction, multiplication and division.

You might also like