aboutsummaryrefslogtreecommitdiff
path: root/AceptaElReto/src/problemas/Problema484ElIncidenteDeDhahran.java
blob: 88ba67479cebb92d428afea0135f822ada322373 (plain)
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
package problemas;

public class Problema484ElIncidenteDeDhahran {

	static java.util.Scanner in;

	public static void main(String args[]) {
		in = new java.util.Scanner(System.in);
		String caso;
		String[] partes;
		String entera;
		String decimal;
		while (in.hasNext()) {
			caso = in.nextLine();

			partes = caso.split("\\.");

			entera = partes[0];
			entera = entera.replaceFirst("^0*", "");
			if (entera.isEmpty())
				System.out.print("0");
			else
				System.out.print(entera);

			if (partes.length > 1) {
				decimal = partes[1];
				decimal = decimal.replaceAll("0*$", "");
				if (decimal.isEmpty())
					System.out.println();
				else
					System.out.println("." + decimal);
			}
			else
				System.out.println();
		}
	}
}