Ayudame con este codigo de java a pasarlo a c++
Publicado por Hose (1 intervención) el 24/11/2020 19:19:07
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
91
92
93
package javaapplication23;
//@author Renzo Staiti
import javax.swing.JOptionPane;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//declara las variables de tipo double, int y string
double horas;
int clase;
String cHoras;
String cClase;
//ingresa por pantalla los valores de las variables
cHoras = JOptionPane.showInputDialog("Ingrese la cantidad de horas trabajadas: ");
cClase = JOptionPane.showInputDialog("Ingrese la clase del trabajador: nClase A(1)nClase B(2)nClase C(3)nClase D(4)");
//convierte las variables string en double e int correspondientemente
horas = Double.parseDouble(cHoras);
clase = Integer.parseInt(cClase);
//comienza el switch
switch (clase) {
case 1:
horas = horas * 7;
JOptionPane.showMessageDialog(null, "Clase " + clase + " Sueldo Total: $" + horas);
break;
case 2:
horas = horas * 5;
JOptionPane.showMessageDialog(null, "Clase " + clase + " Sueldo Total: $" + horas);
break;
case 3:
horas = horas * 4;
JOptionPane.showMessageDialog(null, "Clase " + clase + " Sueldo Total: $" + horas);
break;
case 4:
horas = horas * 3.5;
JOptionPane.showMessageDialog(null, "Clase " + clase + " Sueldo Total: $" + horas);
break;
default:
System.out.println("OPCIÓN INCORRECTA");
}
System.exit(0);
}
}
Valora esta pregunta


0