-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDesafio05.java
41 lines (32 loc) · 1.03 KB
/
Desafio05.java
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
import java.util.Scanner;
public class Desafio05 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String entrada = scanner.nextLine();
String[] partes = entrada.split(",");
String data = partes[0];
String hora = partes[1];
String descricao = partes[2];
double valor = Double.parseDouble(partes[3]);
Transacao transacao = new Transacao(data, hora, descricao, valor);
transacao.imprimir();
}
}
class Transacao {
private String data;
private String hora;
private String descricao;
private double valor;
public Transacao(String data, String hora, String descricao, double valor) {
this.data = data;
this.hora = hora;
this.descricao = descricao;
this.valor = valor;
}
public void imprimir() {
System.out.println(this.descricao);
System.out.println(this.data);
System.out.println(this.hora);
System.out.printf("%.2f", this.valor);
}
}