0

nope it suppose tp conver 0 and 1 into full and half bar as in loop

0

What is wrong with what it is doing now?

What does it do?
What do you want it to do differently?

Edited by NormR1

0

i want to convert the binary code into barcode using fillrect at paint method. which it is not doing

0
char nextChar;
                  int length = NewClass.myBinary.length();
        for(int i = 0; i <length; i++)
        {
                nextChar = NewClass.myBinary.charAt(i);
            if(nextChar == '0')
            {
            g.fillRect(x, y, barWidth, halfBar);    
            }
            else   
            {
               g.fillRect(x, y, barWidth, fullBar);
                       x += barGap;
                        }
0

this suppose to in string myBinary to convert into barcode using fillRect method in above code

0

What does it do when it executes? What is it supposed to draw? Explain in terms of the rectangles and spaces it draws and say what it is doing wrong.

Add some printlns to it to show you the values it computes and where it is drawing with those values.

0

it does not open any GUI it just prints that
System.out.println("The is: " + myBinary); at the top. that all it looks like it never goes through rest of the code.

0

Please post the code that you are executing.
You are trying to do many things that you have not read about how to do. You will continue having problems until you take some time to study how to write a GUI in java.

0

It suppose to print for every zero i have in myBinary

g.fillRect(x, y, barWidth, halfBar) and for every 1 (x, y, barWidth, fullBar); with gap in between

0

It suppose to print for every zero i have in myBinary

What does it print out now? Post what it prints and explain what is wrong with it and show what it should be.

0

It does not print anthing except 1100011000110001100011000110001. it suppose represent evey 0 and 1 with a rectangle some thing like I|||||||||||||||||||||||||||||||||| this in rectange if I have all ones in my binary.

0
public class Digit
{

    private int zip;

   public Digit(int n)
   {
     zip =n;
   }

   /**
      Converts the zip code number to its binary code equivalent

    */
   public String getCode()
   {
      String bar = "";
      if (zip == 1)
         bar = bar +"00011";
      else if (zip == 2)
         bar = bar + "00101";
      else if (zip == 3)
         bar = bar + "00110";
      else if (zip == 4)
         bar = bar + "01001";
      else if (zip == 5)
         bar = bar + "01010";
      else if (zip == 6)
         bar = bar+ "01100";
      else if (zip == 7)
         bar = "10001";
      else if (zip == 8)
         bar = "10010";
      else if (zip == 9)
         bar = bar+ "10100";
      else
         bar = bar +"11000";

      return bar;
   }
   //----------------------------------
   // separate class
   //------------------------------------

public class BarCode
{
    private int zip;
    private String barCode;
    private String val;
    String binary;
   /**

   */
   public BarCode(String n)
   {
      barCode = n;
   }

   /**
      Make 5 digit objects and concatenate

   */
   public String getCode()
   {

      int sum = 0;
      int temp = 0;

      temp = zip / 10000;
      sum = sum + temp;
      Digit d1 = new Digit(temp);
      barCode =  d1.getCode();
      zip = zip % 10000;

      temp = zip / 1000;
      sum = sum + temp;
      Digit d2 = new Digit(temp);
      barCode =  barCode+d2.getCode();
      zip = zip % 1000;

      temp = zip / 100;
      sum = sum + temp;
      Digit d3 = new Digit(temp);
      barCode =  barCode+d3.getCode();
      zip = zip % 100;

      temp = zip / 10;
      sum = sum + temp;
      Digit d4 = new Digit(temp);
      barCode =  barCode+d4.getCode();
      zip = zip % 10;

      temp = zip;
      sum = sum + temp;
      Digit d5 = new Digit(temp);
      barCode = barCode+d5.getCode();

      temp = 10 - (sum % 10);
      Digit d6 = new Digit(temp);
      barCode =  barCode+ d6.getCode() + 1;

      return barCode;
   }




public String Binary(){
return binary;
0

here are other 2 class they do what they mean to do. may be you can find a bug one the other

0

it suppose represent evey 0 and 1 with a rectangle

Can you explain what the code does incorrectly? Can you take a binary number and show what the output is from that number and explain what is wrong with that output?

0

it does not give any out put it supposed to print a GUI accordingly

0

Add some println statements that print out messages to show where it is executing. If nothing prints then you will know that it is not executing.

Why do you think that your code will print anything?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.