-
Lenguaje
Java usando Scanner
-
Descripción
Se ingresan los nombres, código y consumo de luz de varios usuarios.
El cobro por unidad de consumo es: 140 KVH o menos: S/. 3.20
Los siguientes 170 KVH: S/. 0.15 por KVH
Exceso sobre 310 KVH: S/. 0.097 por KVH
Por cada usuario se debe mostrar sus datos y monto a pagar.
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
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
import java.util.Scanner;
public class CobroDelConsumoDeLuz0140310YMasKvh {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double consumo_en_kvh, monto_a_pagar;
String nombre, codigo;
String tecla_repetir;
do {
System.out.print("Ingresa el nombre: ");
nombre = in.nextLine();
System.out.print("Ingresa el codigo: ");
codigo = in.nextLine();
System.out.print("Ingresa el valor de consumo en kvh: ");
consumo_en_kvh = in.nextDouble();
in.nextLine();
in.nextLine();
monto_a_pagar=0;
if(consumo_en_kvh<140)
monto_a_pagar=consumo_en_kvh*3.2;
if(consumo_en_kvh>=140&&consumo_en_kvh<=310)
monto_a_pagar=140.0*3.2+(consumo_en_kvh-140)*0.15;
if(consumo_en_kvh>310)
monto_a_pagar=140.0*3.2+170*0.15(consumo_en_kvh-310)*0.097;
System.out.println("Nombre: " + nombre);
System.out.println("Codigo: " + codigo);
System.out.println("Valor de monto a pagar: " + monto_a_pagar);
System.out.println();
do {
System.out.print("\u00BFDeseas repetir el proceso? (S/N): ");
tecla_repetir = in.nextLine();
} while (!tecla_repetir.equalsIgnoreCase("s") && !tecla_repetir.equalsIgnoreCase("n"));
} while (tecla_repetir.equalsIgnoreCase("s"));
}
}
public class CobroDelConsumoDeLuz0140310YMasKvh {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double consumo_en_kvh, monto_a_pagar;
String nombre, codigo;
String tecla_repetir;
do {
System.out.print("Ingresa el nombre: ");
nombre = in.nextLine();
System.out.print("Ingresa el codigo: ");
codigo = in.nextLine();
System.out.print("Ingresa el valor de consumo en kvh: ");
consumo_en_kvh = in.nextDouble();
in.nextLine();
in.nextLine();
monto_a_pagar=0;
if(consumo_en_kvh<140)
monto_a_pagar=consumo_en_kvh*3.2;
if(consumo_en_kvh>=140&&consumo_en_kvh<=310)
monto_a_pagar=140.0*3.2+(consumo_en_kvh-140)*0.15;
if(consumo_en_kvh>310)
monto_a_pagar=140.0*3.2+170*0.15(consumo_en_kvh-310)*0.097;
System.out.println("Nombre: " + nombre);
System.out.println("Codigo: " + codigo);
System.out.println("Valor de monto a pagar: " + monto_a_pagar);
System.out.println();
do {
System.out.print("\u00BFDeseas repetir el proceso? (S/N): ");
tecla_repetir = in.nextLine();
} while (!tecla_repetir.equalsIgnoreCase("s") && !tecla_repetir.equalsIgnoreCase("n"));
} while (tecla_repetir.equalsIgnoreCase("s"));
}
}