Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NewMain {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         Double x = in.nextDouble();
  8.         int podstawa = in.nextInt();
  9.         int calkowita = x.intValue();
  10.         System.out.println(calkowita);
  11.         double ulamkowa = x - calkowita;
  12.         String wyjscie = "";
  13.         int równanie = 1/2;
  14.         System.out.println(równanie);
  15.        
  16.        
  17.         while (calkowita > 0) {
  18.             wyjscie += calkowita%podstawa;
  19.             calkowita /= podstawa;
  20.  
  21.         }
  22.         StringBuffer sb = new StringBuffer(wyjscie);
  23.         sb.reverse();
  24.         wyjscie =sb.toString()+".";
  25.         while (ulamkowa != 0) {
  26.             ulamkowa = ulamkowa * podstawa;
  27.             int coDodac = (int) (ulamkowa % podstawa);
  28.             wyjscie += coDodac;
  29.             ulamkowa -= coDodac;
  30.         }
  31.         System.out.println(wyjscie);
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement