Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class strings {
- public static int contarCifrasSignificativas(String n) {
- int cs = 0; //cantidad de cifras significativas
- int i=0;
- int posicionPunto = -1;
- for(; i<n.length(); i++) {
- if(n.charAt(i) == '.')
- posicionPunto = i;
- else if(n.charAt(i) != '0')
- break;
- }
- for(; i<n.length(); i++) {
- cs++;
- }
- if(Double.parseDouble(n) == 0.0)
- if(posicionPunto < 0)
- return 0;
- else
- return n.length() - posicionPunto -1;
- return cs;
- }
- public static void main(String[] args) {
- Scanner cin = new Scanner(System.in); // Console IN
- String a = cin.nextLine(), b = cin.nextLine();
- int cs = 0; //cantidad de cifras significativas
- int csa = contarCifrasSignificativas(a);
- int csb = contarCifrasSignificativas(b);
- if(csa == 3 && csb == 3)
- System.out.println(Double.parseDouble(a)*Double.parseDouble(b));
- else
- System.out.println("Las condiciones no se cumplen");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement