Advertisement
Dar954826

Division[ENG].java

Mar 31st, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package eng;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Division {
  6.     private static Scanner dd;
  7.  
  8.     public static void division(String[] args) {
  9.         dd = new Scanner(System.in);
  10.         System.out.print("Insert first division number: ");
  11.         long a = dd.nextLong();
  12.         long e = a;
  13.         System.out.print("Insert second division number: ");
  14.         long b = dd.nextLong();
  15.         System.out.print("Enter at what decimal arrive: ");
  16.         long c = dd.nextLong();
  17.         StringBuilder str = new StringBuilder();
  18.         str.append(Integer.toString((int) (a / b)));
  19.         str.append(".");
  20.         for (int l = 0; l < c; l++) {
  21.             e = (int) (e % b);
  22.             e = Long.parseLong(Long.toString(e) + "0");
  23.             str.append(Long.toString((int) (e / b)));
  24.         }
  25.         int k = str.length();
  26.         while (true) {
  27.             if (str.charAt(k - 1) != 48) {
  28.                 break;
  29.             } else {
  30.                 k--;
  31.             }
  32.  
  33.         }
  34.         str.setLength(k);
  35.  
  36.         System.out.println("\n\nThe result is:");
  37.         System.out.println(str.toString());
  38.     }
  39.  
  40.     public static void main(String[] args) {
  41.         while (true) {
  42.             division(args);
  43.              for (int a = 0; a < 10; a++) {
  44.             System.out.println();
  45.              }
  46.         }
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement