Skip to content

Instantly share code, notes, and snippets.

@EmmaG2
Created October 12, 2023 13:42
Show Gist options
  • Save EmmaG2/7d0f1cd1258579fe9a2f33914e0e7223 to your computer and use it in GitHub Desktop.
Save EmmaG2/7d0f1cd1258579fe9a2f33914e0e7223 to your computer and use it in GitHub Desktop.
Examen de fundamentos de programación del día 12/10/2023
import java.util.Scanner;
public class Examen {
public static void main(String[] args) {
int t = 3, opc, salary;
String name, workerType;
Scanner sc = new Scanner(System.in);
while (t-->0) {
System.out.println("""
Bienvenido, ingresa el tipo de trabajador:
1. Base
2. Interino
3. Eventual
4. Foráneo""");
opc = sc.nextInt();
workerType = getWorkerType(opc);
System.out.println("Nombre: ");
name = sc.next();
System.out.println("Sueldo: ");
salary = sc.nextInt();
if (salary > 12000) System.out.println("Tienes 15% de impuestos: " + (salary * 0.15));
System.out.println("Nombre: " + name);
System.out.println("Sueldo: " + salary);
System.out.println("Tipo de trabajador: " + workerType);
}
}
public static String getWorkerType(int type) {
if (type == 1) return "Base";
if (type == 2) return "Interino";
if (type == 3) return "Eventual";
if (type == 4) return "Foráneo";
return "Opcion invalida";
}
}
import java.util.Scanner;
public class Examen2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = 3, salary;
String name;
while(t-->0) {
System.out.println("nombre: ");
name = sc.next();
System.out.println("Sueldo: ");
salary = sc.nextInt();
System.out.println("Nombre: " + name);
System.out.println("Sueldo total (con reducción de impuestos): " + (salary - (salary * 0.1)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment