0% found this document useful (0 votes)
8 views3 pages

Workshop 1. OOP With Java

This document presents 4 object-oriented programming exercises in Java. The first exercise asks to calculate statistics about people who attended a party. The second exercise involves storing student grades and displaying results. The third exercise models a savings and credit cooperative. The fourth exercise asks to develop a Person class with various attributes and behaviors. Each exercise must be implemented in Java generating the corresponding class diagram.
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)
8 views3 pages

Workshop 1. OOP With Java

This document presents 4 object-oriented programming exercises in Java. The first exercise asks to calculate statistics about people who attended a party. The second exercise involves storing student grades and displaying results. The third exercise models a savings and credit cooperative. The fourth exercise asks to develop a Person class with various attributes and behaviors. Each exercise must be implemented in Java generating the corresponding class diagram.
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/ 3

TECHNOLOGIST IN ANALYSIS AND SYSTEMS DEVELOPMENT

INFORMATION
Workshop 1. OOP with Java

Topics: Objects and classes. Instructions.

For the delivery of the developed files, create a folder with the structure: T1JavaPOO-
NameSurname. Inside this folder include the Netbeans project that contains the exercises.
developed.
This workshop will not use any GUI apart from the JOptionPane class to capture and display messages.
what was seen in previous Workshops.

Products to Deliver: This workshop will be developed individually, develop it consciously. The delivery deadline
The workshop will be announced by the instructor.

1. A party was attended by people of different ages and sexes. Build an application that given the
ages and genders of the people calculated:
How many people attended the party?
How many men and how many women
average_ages_by_gender
The age of the youngest person who attended
No minors allowed at the party
Enter data until an age of zero is entered.

Generate the respective class diagram and create the application in Java that provides a solution to the
requirements.

2. Create a vector of numbers and another of String where we will insert grades between 0 and 10 (we must control that
insert a valid grade), which may be decimal the grade in the array of numbers, in the array of Strings will be inserted
the names of the students. The students will be inserted until the user wishes.

Then, we will create an array of Strings where we will insert the result of the grade in words.

If the grade is between 0 and 4.99, it will be a BAD


If it is between 5 and 6.99, it will be REGULAR.
If it is between 7 and 8.99, it will be a GOOD.

If it is between 9 and 10 it will be an EXCELLENT.

Displays on screen the student's grade and their result in words.

The user will be offered the options of:

Consult the average grades of students who are Excellent


Ing. Diana Lorena Velandia Vanegas
TECHNOLOGIST IN SYSTEMS ANALYSIS AND DEVELOPMENT
INFORMATION

2. Inquire about the number of students who are regular.


Ask the user for the student's name and if it exists, display their numerical grade and in words.
4. Show the student with the highest grade
5. Show the student with the lowest grade

Generate the respective class diagram and create the application in Java that provides a solution to the
requirements.

A savings and credit cooperative establishes the following conditions to determine the maximum value to
to lend for each line of credit.
up to three times the value of the
member's savings.

It is required to develop an algorithm that allows the registration of clients and calculates the maximum amount to be lent to a
partner according to the requested credit line and the value of the partner's savings.
Credit lines are coded as 1= Education, 2 = Vacation, 3= Vehicle, 4= Housing. Send a
message in case one of the previous codes is not registered. The information that will be requested from
Member is the name, type of labor link (contractor, permanent) and value of the savings.
Once the information is entered, the application should display a message on the screen:

and for
plant employees have a 3% discount on the value of the housing loan.

We have a 2% discount on auto loans.

The application must allow the user to inquire about another different credit until they wish to exit.
The client and the queried line must be stored in a vector or an array. At the end, it will be displayed.
a report that includes:
Number of inquiries made by type of credit.
Number of contractor clients
Average savings that plant customers have.

Generate the respective class diagram and create the application in Java that provides a solution to the
requirements

4. Develop a class called Person that meets the following conditions:


• Its attributes are: name, age, ID number, gender (H for man, M for woman), weight, and height. We do not want it to
they access them directly. Think about which access modifier is the most appropriate, as well as its type. If
If you want to add an attribute, you can do it.
2Ing. Diana Lorena Velandia Vanegas
Technologist in Systems Analysis and Development
INFORMATION
• By default, all attributes except the ID number will be default values according to their type (0 numbers,
empty string for String, etc.). Sex will be male by default, use a constant for that.
• Several builders will be implanted:
o A default constructor.
o A constructor with name, age, and gender, the rest by default.
o A constructor with all attributes as parameters.
• The methods that will be implemented are:
o calculateBMI(): it will calculate whether the person is at their ideal weight (weight in kg / (height^2 in m)), returns a -
1 if you are below your ideal weight, 0 if you are at your ideal weight, and 1 if you are overweight. I recommend you.
Use constants to return these values.
o isOfLegalAge(): indicates whether they are of legal age, returns a boolean.
o checkSex(char sex): checks that the entered sex is correct. If it is not correct, it will be 'H'.
o toString(): returns all the information of the object.
o generateDNI(): generates a random 8-digit number. This method will be invoked when building
the object.
o Set methods for each parameter, except for DNI.
Now, create an executable class that does the following:
• Ask for the name, age, sex, weight, and height via keyboard.
• Create a list of objects from the previous class until the user wishes to exit.
• For each object, you must check if it is at its ideal weight, overweight, or underweight.
ideal with a message.
• Indicate for each object whether it is of legal age.
• Finally, display the information of each object.
You can use methods in the executable class to make it easier.
Generate the corresponding class diagram and create the application in Java that provides a solution to the
requirements

3Ing. Diana Lorena Velandia Vanegas

You might also like