Telegram Group & Telegram Channel
15. Program to Convert Decimal to Binary.

import java.util.Scanner;

class DecimalToBinary
{

public String toBinary(int n)
{
if (n == 0)
{
return "0";
}

String binary = "";
while (n > 0)
{
int rem = n % 2;
binary = rem + binary;
n = n / 2;
}

return binary;
}

public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int decimal = scanner.nextInt();

DecimalToBinary decimalToBinary = new DecimalToBinary();
String binary = decimalToBinary.toBinary(decimal);

System.out.println("The binary representation is " + binary);
}
}

@java_codings



tg-me.com/java_codings/24
Create:
Last Update:

15. Program to Convert Decimal to Binary.

import java.util.Scanner;

class DecimalToBinary
{

public String toBinary(int n)
{
if (n == 0)
{
return "0";
}

String binary = "";
while (n > 0)
{
int rem = n % 2;
binary = rem + binary;
n = n / 2;
}

return binary;
}

public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int decimal = scanner.nextInt();

DecimalToBinary decimalToBinary = new DecimalToBinary();
String binary = decimalToBinary.toBinary(decimal);

System.out.println("The binary representation is " + binary);
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_codings/24

View MORE
Open in Telegram


Advance Java ‍ Telegram | DID YOU KNOW?

Date: |

How Does Telegram Make Money?

Telegram is a free app and runs on donations. According to a blog on the telegram: We believe in fast and secure messaging that is also 100% free. Pavel Durov, who shares our vision, supplied Telegram with a generous donation, so we have quite enough money for the time being. If Telegram runs out, we will introduce non-essential paid options to support the infrastructure and finance developer salaries. But making profits will never be an end-goal for Telegram.

What is Telegram?

Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.

Advance Java ‍ from pl


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM USA