CSCI207 Lab3
CSCI207 Lab3
USAL
CSCI207 – Lab3 Fall 2022
Problem 1: (Classes)
Objectives:
In this lab, you will practice:
1. Creating a class declaration.
2. Declaring instance variables.
3. Declaring a constructor.
4. Declaring set and get methods.
5. Writing a test application to demonstrate the capabilities of another
class.
6. Create a UML for your class.
Problem-Solving Tips
1. Class Employee should declare three instance variables.
2. The constructor must declare three parameters, one for each instance variable. The
value for the salary should be validated to ensure it is not negative.
3. Declare a public set and get method for each instance variable. The set methods
should not return values and should each specify a parameter of a type that matches
the corresponding instance variable (String for first name and last name, double for the
salary). The get methods should receive no parameters and should specify a return type
that matches the corresponding instance variable.
4. When you call the constructor from the test class, you must pass it three arguments
that match the parameters declared by the constructor.
5. Giving each employee a raise will require a call to the get method for the salary to
obtain the current salary and a call to the set method for the salary to specify the new
salary.
6. A salary is a dollar amount, so you should output the salary using the %.2f specifier to
provide two digits of precision.
Problem 2:
Create a program that do the following tasks:
1- Let the user select a file using the java file chooser.
2- Read from the select file all lines.
3- At each line you need to get the name and 4 integers from
string with a “-“ between each integer ex: “Ali_Ali-18-20-12-
15”
4- For each line calculate the averge of each student and write
the data to another files called “grades.txt” as follows:
“Ali_Ali: 15/20 passed “
5- Close files
6- You can do your checks for the format of the file or if exists
or if no lines found to show the error message to user