importar java.util.Scanner;
clase pública LibertySalesCampaign {
// Constantes para precios de paquetes
doble final estático privado INTERNET_ONLY = 30.0;
doble final estático privado INTERNET_CABLE = 50.0;
doble final estático privado INTERNET_CABLE_PREMIUM = 75.0;
// objeto escáner para entrada
escáner de escáner estático privado = nuevo escáner (System.in);
público estático vacío principal (String [] argumentos) {
System.out.println("Bienvenido a la campaña de ventas de Liberty");
// Obtener la elección del paquete por parte del usuario
System.out.println("Seleccione su paquete:");
System.out.println("1 - Sólo Internet ($30)");
System.out.println("2 - Internet y cable ($50)");
System.out.println("3 - Internet, Cable y 3 canales Premium ($75)");
int eleccióndelpaquete = scanner.nextInt();
// Obtener información sobre servicios anteriores
System.out.println("¿Tiene algún servicio previo con nosotros? (sí/no)");
boolean hasPreviousServices = scanner.next().equalsIgnoreCase("sí");
double Preciobase = getPackagePrice(packageChoice);
si (tieneServiciosPrevios) {
System.out.println("¿Está usted en mora? (sí/no)");
boolean inArrears = scanner.next().equalsIgnoreCase("sí");
int meses en atraso = 0;
si (en mora) {
System.out.println("¿Cuántos meses tienes de atraso?");
mesesAtrasados = scanner.nextInt();
}
Preciobase = calcularPrecioFinal(Preciobase, verdadero, mesesAtrasados);
} demás {
Preciobase = calcularPrecioFinal(Preciobase, falso, 0);
}
System.out.println("El monto total a pagar por mes es: $" + String.format("%.2f", basePrice));
}
getPackagePrice doble estático privado (elección int) {
cambiar (elección) {
caso 1:
devolver INTERNET_ONLY;
caso 2:
devolver INTERNET_CABLE;
caso 3:
devolver INTERNET_CABLE_PREMIUM;
por defecto:
System.out.println("Elección no válida. El valor predeterminado es Sólo Internet.");
devolver INTERNET_ONLY;
}
}
cálculo doble estático privadoPrecioFinal(preciobasedoble, booleano tieneServiciosPrevios, int mesesAtrasados) {
double Precio final = Precio base;
si (tieneServiciosPrevios) {
Precio final *= 0,90; // Aplicar 10% de descuento
si (meses atrasados > 0) {
for (int i = 0; i < meses en atrasos; i++) {
Precio final *= 1,13; // Aplicar 13% de impuesto por mes vencido
}
}
}
devolver precio final;
}
}