unresolved compilation problem (JAVA)
Publicado por AFB (10 intervenciones) el 20/04/2020 19:48:08
A continuación el código para el ejemplo:
--
--
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
JWpackage Pkg01;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/* Como debería funcionar y qué se espera:
* Ingresar por consola un código de dos caracteres:
* Los correctos pueden ser "AH" o "JW"
*El sistema debería mostrar en consola los datos del empleado correspondiente al código
*/
public class Employee01 {
String name;
int age;
String designation;
double salary;
// -------------
// This is the constructor of the class Employee
public Employee01(String name) {
this.name = name;
}
// Assign the age of the Employee to the variable age.
public void empAge(int empAge) {
age = empAge;
}
/* Assign the designation to the variable designation. */
public void empDesignation(String empDesig) {
designation = empDesig;
}
// Assign the salary to the variable salary.
public void empSalary(double empSal) {
salary = empSal;
}
/* Print the Employee details */
public void printEmployee() {
System.out.println("name : " + name);
System.out.println("age :" + age);
System.out.println("designation : " + designation);
System.out.println("salary :" + salary);
}
// -----------
// call constructor to initialize objects as follows:
public static void main(String args[]) throws IOException {
//Notar que readLine() nos obliga a declarar IOException
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //Ya tenemos el "lector"
System.out.println("Ingrese codigo de dos letras en MAYUSCULA");//Se pide un dato al usuario
String codalfabetico = br.readLine(); //Se lee el nombre con readLine() que retorna un String con el dato
switch (codalfabetico) {
case "AH":
Employee01 empThree = new Employee01("Anne Hamerson");
empThree.empAge(26);
empThree.empDesignation("Senior Software Engineer");
empThree.empSalary(1000);
empThree.printEmployee();
break;
case "JW": Employee01 empFour = new Employee01("James Witoquin");
empFour.empAge(21);
empFour.empDesignation("Software Engineer");
empFour.empSalary(500);
empFour.printEmployee();
break;
default: System.out.println("El código no corresponde a un empleado");
System.out.println(codalfabetico);
}
}
}
/*---------------------------------------
La version de java en uso es:
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
Al hacer run as java apllication el mensaje es:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
*/
Valora esta pregunta


0