Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NewMain {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- Double x = in.nextDouble();
- int podstawa = in.nextInt();
- int calkowita = x.intValue();
- double ulamkowa = x - calkowita;
- String wyjscie = "";
- while (calkowita > 0) {
- wyjscie += calkowita % podstawa;
- calkowita /= podstawa;
- }
- StringBuffer sb = new StringBuffer(wyjscie);
- sb.reverse();
- wyjscie = sb.toString() + ".";
- while (ulamkowa != 0) {
- ulamkowa = ulamkowa * podstawa;
- int coDodac = (int) (ulamkowa % podstawa);
- wyjscie += coDodac;
- ulamkowa -= coDodac;
- }
- System.out.println(wyjscie);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement