Skip to main content

Posts

Showing posts from August, 2014

Binary Converter - Netbeans Java Codes

You can also download text file of this code here:   BinaryConverter.txt Java Code: public class BinaryConv { public static void main(String[] args) { Scanner in = new Scanner(System.in); int decimalNumber; String binaryNumber; System.out.print("Enter a positive integer: "); decimalNumber = in.nextInt(); if (decimalNumber <= 0) System.out.println("ERROR: entered integer is nonpositive."); else { binaryNumber = ""; // algorithm step by step // initial: binaryNumber = "", decimalNumber = 123 // step 1 : binaryNumber = "1 ", decimalNumber = 61 // step 2 : binaryNumber = "11 ", decimalNumber = 30 // step 3 : binaryNumber = "011 ", decimalNumber = 15 // step 4 : binaryNumber = "1011 ", decimalNumber = 7 // step 5 : binaryNumber = "1 1011 ", decimalNumber = 3 // step 6 : binaryNumber = "11 1011 ", decimalNumber = 1 // step 6 : binaryNumber = "111 1011 ",

Display Text in Blue and Green Colours - Netbeans Java Codes

You can also download text file of this code here:   Blue-Greentexts.txt Java Codes: public class ActionExample extends Applet implements ActionListener { AudioClip audio; Button okButton; Button wrongButton; TextField nameField; CheckboxGroup radioGroup; Checkbox radio1; Checkbox radio2; Checkbox radio3; public void init() { // Now we will use the FlowLayout[Find More Java Codes at www.sumikuma.tk] setLayout(new FlowLayout()); okButton = new Button("Action!"); wrongButton = new Button("Don't click!"); nameField = new TextField("Type here Something",35); radioGroup = new CheckboxGroup(); radio1 = new Checkbox("Red", radioGroup,false); radio2 = new Checkbox("Blue", radioGroup,true); radio3 = new Checkbox("Green", radioGroup,false); add(okButton); add(wrongButton);

Captcha - Netbeans Java Codes

You can also download text file of this code here:   Captcha.txt Java Code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // [Find More Java Codes at www.sumikuma.tk] if ("Cleven Eleven".equals(txt1.getText())) JOptionPane.showMessageDialog(this,"You answer is correct"); else JOptionPane.showMessageDialog(null, "You are unsuccessful, Please Try Again"); } How To Display Image? : jLabel1>Properties>Icon>(Under External Image) Import to Image>Select Suitable Image from File Chooser>Select Target Folder>Click Ok> Close the Properties Window. [Find More Java Codes at www.sumikuma.tk]

Display Even-Odd Numbers Series - Netbeans Java Project

You can also download text file of this code here:  Even-Odd.txt Java Code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // [Find More Java Codes at www.sumikuma.tk] int LastNumber = Integer.parseInt(jTextField1.getText()); if (jRadioButton1.isSelected()) { for (int I = 2; I<=LastNumber; I+=2) jTextArea1.setText(jTextArea1.getText()+" " +Integer.toString(I)); } else if (jRadioButton2.isSelected()) { for (int I = 1; I<=LastNumber; I+=2) jTextArea1.setText(jTextArea1.getText()+" " + Integer.toString(I)); } else JOptionPane.showMessageDialog(this, "Click to select [Even] or [Odd] Option"); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

Find Greatest Common Division - Netbeans Java Codes

You can also download text file of this code here:   GCD.txt Java Code: public class GreatestCommonDivisor { public static void main(String args[]){ //Enter two number whose GCD needs to be calculated. [Find More Java Codes at www.sumikuma.tk] Scanner scanner = new Scanner(System.in); System.out.println("Please enter first number to find GCD"); int number1 = scanner.nextInt(); System.out.println("Please enter second number to find GCD"); int number2 = scanner.nextInt(); System.out.println("GCD of two numbers " + number1 +" and " + number2 +" is :" + findGCD(number1,number2)); } /* * Java method to find GCD of two number using Euclid's method * @return GDC of two numbers in Java[Find More Java Codes at www.sumikuma.tk] */ private static int findGCD(int number1, int number2) {

Place An Order In Hotel Menu - Netbeans Java Codes

You can also download text file of this code here:   MenuOrder.txt Java Code: private void btn1ActionPerformed(java.awt.event.ActionEvent evt) { int Total = 0; if (lt1.isSelectedIndex(0)==true) { Total = Total+150; JOptionPane.showMessageDialog(this,"Bhel Puri Ordered Rs. 150"); } if (lt1.isSelectedIndex(1)==true) { Total = Total+300; JOptionPane.showMessageDialog(this,"Pasta Ordered Rs. 300"); } if (lt1.isSelectedIndex(2)==true) { Total = Total+200; JOptionPane.showMessageDialog(this,"Pizza Ordered Rs. 200"); } if (lt1.isSelectedIndex(3)==true) { Total = Total+180; JOptionPane.showMessageDialog(this,"Burger Ordered Rs. 180"); } if (lt1.isSelectedIndex(4)==true) { Total = Total+220

To Check a Number is Palindrome - Netbeans Java Codes

You can also download text file of this code here:   Palindrome.txt Java Code: int num = Integer.parseInt(txt1.getText()); int n; n = num; int rev = 0; while (num!=0) { int r = num%10; num = num/10; rev = rev*10+r; } if (n==rev) { JOptionPane.showMessageDialog(null, "It Is a Palindrome"); } else { JOptionPane.showMessageDialog(null, "It Is Not A Palindrome"); } [Find More Java Code at www.sumikuma.tk

List of Natural Numbers - Netbeans Java Codes

You can also download text file of this code here:   NaturalNum.txt Java Code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int a = Integer.parseInt(txt1.getText()); for (int I = 1; I<=a; I++) txt2.setText(txt2.getText() + " " + Integer.toString(I)); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } [Find More Java Codes at www.sumikuma.tk]

Scrambld - Netbeans Java Codes

You can also download text file of this code here:   Scrambld.txt Java Code: public class ScrambleWords extends javax.swing.JFrame { public ScrambleWords() { initComponents(); check.setVisible(false); } int count=0; String st =""; private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) { count++; if(count<=8){ st=st+jLabel1.getText(); ans.setText(st);; } if(count>=8) check.setVisible(true); private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) { count++; if(count<=8){ st=st+jLabel2.getText(); ans.setText(st);; } if(count>=8) check.setVisible(true); } private void jLabel10MouseClicked(java.awt.event.MouseEvent evt) { count++; i

Tic Tac Toe - Netbeans Java Codes

Java Code: public class TicTacToe implements ActionListener { final String VERSION = "1.0"; //Setting up ALL the variables[Find More Java Codes at www.sumikuma.tk] JFrame window = new JFrame("Tic-Tac-Toe " + VERSION); JMenuBar mnuMain = new JMenuBar(); JMenuItem mnuNewGame = new JMenuItem("New Game"), mnuInstruction = new JMenuItem("Instructions"), mnuExit = new JMenuItem("Exit"), mnuAbout = new JMenuItem("About"); JButton btn1v1 = new JButton("Player vs Player"), btn1vCPU = new JButton("Player vs CPU"), btnBack = new JButton("<--back"); JButton btnEmpty[] = new JButton[10]; JPanel pnlNewGame = new JPanel(), pnlNorth = new JPanel(), pnlSouth = new JPanel(), pnlTop = new JPanel(), pnlBottom = new JPanel(), pnlPlayingField = new JPanel(); JLabel lblTitle = new JLabel("Tic-Tac-Toe"); JTextArea txtMessage = new JTextArea(); final int winCombo[][] = new int[][] { {1, 2, 3}, {

Text File Viewer - Netbeans Java Codes

Java Code: import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.swing.JFileChooser; class MyCustomFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File file){ return file.isDirectory()|| file.getAbsolutePath().endsWith(".txt"); } @Override public String getDescription() { return "Video File (*.txt)"; } } private void MenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // [Find More Java Codes at www.sumikuma.tk] int returnVal = fileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ File file = fileChooser.getSelectedFile(); try { textarea.read(new FileReader(file.getAbsolutePath()),null); } catch (IOException ex) { System.out.print

Eligible To Vote - Netbeans Java Codes

Java Code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //[Find More Java Codes at www.sumikuma.tk] if (Integer.parseInt(txt1.getText())>=18) JOptionPane.showMessageDialog(null, "You are Eligible To Vote"); else JOptionPane.showMessageDialog(null,"You are not Eligible To Vote"); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // [Find More Java Codes at www.sumikuma.tk] System.exit(0); } [Find More Java Codes at www.sumikuma.tk] You can also download text file of this code here: Vote.txt