Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercise_10;
- import java.util.Scanner;
- public class Exercise_10 {
- public static void main(String[] args) {
- int decimal, partition, remainder;
- String binary = "";
- Scanner input = new Scanner(System.in);
- System.out.print("Въведи позитивно десетично число: ");
- decimal = input.nextInt();
- do {
- partition = decimal / 2;
- remainder = decimal % 2;
- decimal = partition;
- binary += remainder;
- }
- while (partition != 0);
- System.out.println("Конвертирано в двоично число е: " + binary);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement