Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ You must follow the **SDLC process** to refactor the code:
- Once you complete the refactorization, push your changes to your forked repository.
- Create a pull request (PR) to the original repository, explaining the improvements you made and how you followed the **SDLC** approach.

//Haider Carreño 192350
26 changes: 19 additions & 7 deletions src/AgeValidation.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import java.util.Scanner;

public class AgeValidation {
// 1 defino constantes
private static final int AGE_LIMIT = 18; // edad limite para el acceso

public static void main(String[] args) {
int age = 18;
// 2 manejo la entrada del usuario
Scanner scanner = new Scanner(System.in);

if (age >= 18) {
System.out.println("Access granted");
System.out.print("Enter your age: ");
int age = scanner.nextInt(); // lee edad del usuario

// 3 estructura if-else para validar la edad
if (age >= AGE_LIMIT) {
System.out.println("Access granted"); // si la edad es mayor o igual al limite acceso concedido
} else {
System.out.println("Access denied"); // si la edad es menor al limite acceso denegado
}

// cerrar el Scanner
scanner.close();

if (age < 18) {
System.out.println("Access denied");
}
}
}
}
35 changes: 35 additions & 0 deletions src/Quiz2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
public class Quiz2 {

// 1 Reemplazar numeros magicos con nombres de constantes
static final int PRODUCT_1_PRICE = 15;
static final int PRODUCT_2_PRICE = 10;
static final int PRODUCT_3_PRICE = 5;
static final int QUANTITY_1 = 2;
static final int QUANTITY_2 = 3;
static final int QUANTITY_3 = 4;
static final int SALES_THRESHOLD = 50;

public static void main(String[] args) {

// 2 Diseño e Implementacion
// Arrays para almacenar precios y cantidades de productos
int[] productPrices = {PRODUCT_1_PRICE, PRODUCT_2_PRICE, PRODUCT_3_PRICE};
int[] productQuantities = {QUANTITY_1, QUANTITY_2, QUANTITY_3};

// variable de las ventas totales de la tienda
int totalSales = 0;

// calcular ventas totales usando ciclo repetitivo for
for (int i = 0; i < productPrices.length; i++) {
totalSales += productPrices[i] * productQuantities[i];
}

// 4 Comprobar resultados de las ventas
if (totalSales > SALES_THRESHOLD) {
System.out.println("Good sales performance");
} else {
System.out.println("Low sales performance");
}
}
}

28 changes: 28 additions & 0 deletions src/Quiz3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class Quiz3 {

// Fase 1 Reemplazo numeros magicos por constantes
static final double TAX_RATE_HIGH = 0.15;
static final double TAX_RATE_LOW = 0.10;
static final double TAX_THRESHOLD = 50.0;

public static void main(String[] args) {

// Fase 2 Diseño y arrays para almacenar los precios de los productos y los tipos
double[] productPrices = {100, 200};
double[] taxRates = {TAX_RATE_HIGH, TAX_RATE_LOW};

// Fase 3: Aplicación y calculo de los impuestos
double totalTax = 0;
for (int i = 0; i < productPrices.length; i++) {
totalTax += productPrices[i] * taxRates[i];
}

// Fase 4 Comprobar si el impuesto total supera el limite
if (totalTax > TAX_THRESHOLD) {
System.out.println("High total tax: " + totalTax);
} else {
System.out.println("Low tax");
}
}
}

19 changes: 0 additions & 19 deletions src/Store.java

This file was deleted.

15 changes: 0 additions & 15 deletions src/TaxCalculation.java

This file was deleted.