Posts

Showing posts with the label Java Program

Java Program for Converting Decimal to Binary

Hi Friends.. Today I am going to post a small program to convert any user given decimal number to its corresponding binary value. //DecimalToBinary.java import java.util.Scanner; public class DecimalToBinary {     static void decimalToBinary(int value){ int rem =0; String res = "" ; while ( value >0){     rem = value %2;       res = res + rem ;     value  /=2; } System. out .println( new  StringBuilder( res ).reverse());    }    public static void main(String[] args){     System.out.print("Enter the Decimal Value: ");     Scanner scanner = new Scanner(System. in );      int val = scanner .nextInt();     decimalToBinary(val);    } } Execute and Enjoy.. 😉

NotePad Project in Java

Image
Hi Friends... A Notepad Project.. Suggest me if any modification and bugs are there. Feel free to query. package notepad; //NOTEPAD PROJECT  import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.undo.*; import java.awt.*; //FOR UNDO import java.io.*; import javax.swing.filechooser.FileFilter; //FOR FILE CHOOSER FOR OPEN AND SAVE MENU  import javax.swing.filechooser.FileNameExtensionFilter; //FILTER FOR FILE CHOOSER  import java.util.*; public class notepad extends JFrame implements ActionListener { public static JTextArea area; JMenuBar mb; JMenu file, edit, format, help; JMenuItem new1, open, save, saveas, exit1, find, findn, delete, got, selectA, timedate, cut1, copy1, paste1, font, vhelp, about; JCheckBoxMenuItem wordwrap; JScrollPane sp; String filename = "Untitled";// DEFAULT DOCUMENT TITLE public static UndoManager undo = new UndoManager(); public static UndoAction undoAction = new UndoAction(); boolean opened = false;...