You are on page 1of 3

ACTIVIDAD 9 Enter your choice (1—4):

Fecha Límite: Hasta las 23:59 del 7 de noviembre de


Display an error message if the user enters a number
2023
outside the range of 1 through 4 when selecting an
item from the menu.
Cada grupo debe hacer el código en Java usando Eclipse,
y realizar las validaciones necesarias usando el ciclo 2. Grupo 4 (CHARRY FUENTES, DANIEL FELIPE;
while. SANCHEZ MARTINEZ, XIMENA)

El Proyecto en JAVA deben tener como nombre de (Employee Class). Design an Employee class
archivo, un nombre compuesto por: Act9 + Solamente with the following constructors:
un nombre y un apellido de cada uno de los integrantes
del grupo. • A constructor that accepts the following values
Ejemplo: as arguments and assigns them to the appropriate
Act9_AngiePerezCarlosArrietaAndreaHuertas.zip fields: employee’s name, employee’s ID
number, department, and position.
1. Grupo 3 (TORRES TORRES, KAREN ALEJANDRA) • A constructor that accepts the following values
as arguments and assigns them to the appropriate
(Geometry Calculator). Design a Geometry fields: employee’s name and ID number. The
class with the following methods: department and position fields should be
assigned an empty string (" ").
• A static method that accepts the radii of an • A no-arg constructor that assigns empty strings
ellipse and returns the area of the ellipse. Use (" ") to the name, department, and position
the following formula: fields, and 0 to the idNumber field.

𝐴𝑟𝑒𝑎 = 𝜋𝑟1 𝑟2 Write a program that tests and demonstrates these


constructors. Be creative!
Use Math.PI for 𝝅.
3. Grupo 7 (NIETO RODRIGUEZ, SANTIAGO)
• A static method that accepts the length and
width of a rectangle and returns the area of (Perfect Numbers). An integer number is said to be
the rectangle. Use the following formula: a perfect number if its factors, including 1 (but not the
number itself), sum to the number. For example, 6 is
𝐴𝑟𝑒𝑎 = 𝐿𝑒𝑛𝑔𝑡ℎ 𝑥 𝑊𝑖𝑑𝑡ℎ a perfect number, because 6 =1 + 2 + 3. Write a static
method isPerfect that determines if parameter
• A static method that accepts the length of a number is a perfect number. Use this method in an
triangle’s base and the triangle’s height. The application that displays all the perfect numbers
method should return the area of the triangle. between 1 and 1000. Display the factors of each
Use the following formula: perfect number to confirm that the number is indeed
perfect. Challenge the computing power of your
𝐴𝑟𝑒𝑎 = 𝐵𝑎𝑠𝑒 𝑥 𝐴𝑙𝑡𝑢𝑟𝑎 𝑥 0.5 computer by testing numbers much larger than 1000.
Display the results.
The methods should display an error message if
negative values are used for the ellipse’s radii, the
rectangle’s length or width, or the triangle’s base or 4. Grupo 2 (CARRILLO CLEVES, DANIEL ALEJANDRO)
height.
Cree una clase llamada CuentaDeAhorros. Use
Next, write a program to test the class, which displays
una variable static llamada
the following menu and responds to the user’s
tasaInteresAnual para guardar la tasa de
selection:
interés anual para todos los cuentahabientes. Cada
Geometry Calculator objeto de la clase debe contener una variable de
1. Calculate the Area of an Ellipse instancia private llamada saldoAhorros, que
2. Calculate the Area of a Rectangle identifique la cantidad que el ahorrador tiene
3. Calculate the Area of a Triangle actualmente en depósito. Proporcione el método
4. Quit calcularInteresMensual para calcular el
interés mensual, multiplicando el saldoAhorros b) Method fahrenheit returns the Fahrenheit
por la tasaInteresAnual dividida entre 12; este equivalent of a Celsius temperature, using the
interés debe sumarse al saldoAhorros. calculation
Proporcione un método static llamado fahrenheit = 9.0 / 5.0 * celsius + 32;
modificarTasaInteres para establecer la
tasaInteresAnual en un nuevo valor. Use the methods from parts (a) and (b) to write an
application that enables the user either to enter a
Escriba un programa para probar la clase Fahrenheit temperature and display the Celsius
CuentaDeAhorros. Cree dos instancias de objetos equivalent or to enter a Celsius temperature and
display the Fahrenheit equivalent.
CuentaDeAhorros, ahorrador1 y
ahorrador2, con saldos de $2000.00 y $3000.00,
respectivamente. Establezca la 7. Grupo 1 (PENA POSSO, JUAN CARLOS)
tasaInteresAnual en 4%, después calcule el
interés mensual e imprima los nuevos saldos para (Population). Write a class that will predict the size
ambos ahorradores. Luego establezca la of a population of organisms. The class should store
tasaInteresAnual en 5%, calcule el interés del the starting number of organisms, their average daily
siguiente mes e imprima los nuevos saldos para population increase (as a percentage), and the number
of days they will multiply. The class constructor
ambos ahorradores.
should initialize these three fields. The class should
also have a private method that uses a loop to display
5. Grupo 11 (PEREZ GARZON, SANTIAGO) the size of the population for each day, this method is
called from the constructor.
(Area Class). Write a class that has three
overloaded static methods for calculating the areas of Test the class in a program that displays the daily
the following geometric shapes. population.
• circles
• rectangles Input Validation: Do not accept a number less than
• cylinders 2 for the starting size of the population. Do not accept
a negative number for average daily population
Here are the formulas for calculating the area of the increase. Do not accept a number less than 1 for the
shapes. number of days they will multiply.

Area of a circle: 𝐴𝑟𝑒𝑎 = 𝜋𝑟 2 8. Grupo 10 (FAJARDO AGUIRRE, JUAN DAVID)

Where 𝝅 is Math.PI, r is the circle’s radius (Larger Than n). In a class, write a method that
accepts two arguments: an array and a number n.
Area of a rectangle: 𝐴𝑟𝑒𝑎 = 𝑊𝑖𝑑𝑡ℎ 𝑥 𝐿𝑒𝑛𝑔𝑡ℎ Assume that the array contains integers. The method
Area of a cylinder: 𝐴𝑟𝑒𝑎 = 𝜋𝑟 2 ℎ should display all of the numbers in the array that are
greater than the number n.
Where 𝝅 is Math.PI, r is the radius of the cylinder’s
base, and h is the cylinder’s height. Demonstrate the class in a complete program that
Because the three methods are to be overloaded, they calls the method.
should each have the same name, but different
parameter lists. Demonstrate the class in a complete 9. Grupo 6 (LONDONO CARDENAS, JEFFERSON DAVID;
program. RIVERA QUINTERO, CAMILO; TAVERA QUIROZ,
EMERSON STIVER)
6. Grupo 9 (CAICEDO TORO, RICHARD SANTIAGO)
(Payroll Class). Write a Payroll class that uses
(Temperature Conversions). Implement the the following arrays as fields:
following static methods:
- employeeId. An array of seven integers to
a) Method celsius returns the Celsius equivalent hold employee identification numbers. The array
of a Fahrenheit temperature, using the calculation should be initialized with the following numbers:
celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
5658845 4520125 7895122 8777541
8451277 1302850 7580489
Demonstrate the class in a program that allows the
- hours. An array of seven integers to hold the user to enter each student’s name and his or her four
number of hours worked by each employee. test scores. It should then display each student’s
- payRate. An array of seven doubles to hold average test score and letter grade.
each employee’s hourly pay rate.
- wages. An array of seven doubles to hold each Input validation: Do not accept test scores less than
employee’s gross wages. zero or greater than 100.

The class should relate the data in each array through 11. Grupo 8 (PINEDA QUIROGA, JUAN SEBASTIAN)
the subscripts. For example, the number in element 0
of the hours array should be the number of hours (ArrayOperations Class). Write a class name
worked by the employee whose identification number ArrayOperations with the following static
is stored in element 0 of the employeeId array. methods:
That same employee’s pay rate should be stored in - getTotal. This method should accept a one-
element 0 of the payRate array. dimensional array as its argument and return the
total of the values in the array.
In addition to the appropriate accessor (get) and - getAverage. This method should accept a one-
mutator (set) methods, the class should have a method dimensional array as its argument and return the
that accepts an employee’s identification number as average of the values in the array.
an argument and returns the gross pay for that - getHighest. This method should accept a one-
employee. dimensional array as its argument and return the
highest value in the array.
Demonstrate the class in a complete program that - getLowest. This method should accept a one-
displays each employee number and asks the user to dimensional array as its argument and return the
enter that employee’s hours and pay rate. It should lowest value in the array.
then display each employee’s identification number
and gross wages. Demonstrate the class in a complete program with test
data stored in arrays of various data types.
Input Validation: Do not accept negative values for
hours or numbers less than 6.00 for pay rate.

10. Grupo 5 (BARACALDO ARIAS, DEISY DAYANA;


SANCHEZ NIETO, JUAN PABLO; SANDOVAL HAMON,
LAURA VALENTINA)

(Grade Book). A teacher has five students who have


taken four tests. The teacher uses the following
grading scale to assign a letter grade to a student,
based on the average of his or her four test scores.

Test Score Letter Grade


90–100 A
80–89 B
70–79 C
60–69 D
0–59 F

Write a class that uses a String array to hold the


five students’ names, an array of five characters to
hold the five students’ letter grades, and five arrays of
four doubles each to hold each student’s set of test
scores. The class should have methods that return a
specific student’s name, average test score, and a
letter grade based on the average.

You might also like