Professional Documents
Culture Documents
LAB # 2
1. Create a design for the mark sheet by taking the runtime value of the
student’s name, total marks, and obtained marks and calculating its
percentage, grade, and GPA. Use good practices of programming that we
have studied and ensure that the outcomes should be presented in a proper
Viewable approach.
Source Code:
import java.util.Scanner;
char grade;
Output:
2. Create a class Rectangle with attributes length and width, each of which
defaults to 1. Provide methods that calculate the rectangle’s perimeter and
SWE-312 Software Construction and Development SSUET/QR/114
area. It has set and get methods for both length and width. The set methods
should verify that length and width are each floating-point number larger
than 0.0 and less than 20.0. Write a program to test class Rectangle.
Source Code:
public class Rectangle {
private double length;
private double width;
3. Convert the following class diagram into optimized and meaningful java
code.
SWE-312 Software Construction and Development SSUET/QR/114
Source Code:
SWE-312 Software Construction and Development SSUET/QR/114
SWE-312 Software Construction and Development SSUET/QR/114
Output:
SWE-312 Software Construction and Development SSUET/QR/114