# Haha. Laughing at my ultimate longest code ever.

Page 1 of 1

## 2 Replies - 5339 Views - Last Post: 28 September 2017 - 01:37 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=406527&amp;s=459727a59d15a918fcaf6b459dccf672&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Yureeh_30

Reputation: 0
• Posts: 2
• Joined: 27-September 17

# Haha. Laughing at my ultimate longest code ever.

Posted 27 September 2017 - 08:18 AM

Hi, im ree new in here and also on programming. Our sir taught things but i can only master was the joptionpane. Anyway our sir told us to convert decimal to other number system with our own understanding. 😎i have a wonderful mind so i made that😋😂😂(i cant believed i made that!! Im so embarrass😄 because i know i can easily ask google for help and/or my classmates😄😅😂😂😂) by the way😈 enjoy😂😂!(note: its working😂 with limitations😂)
```import javax.swing.JOptionPane;
public class DecimalToBinary{
public static void main (String[] args) {

String Decimal;
int deci, rone, rtwo, rthree, rfour, rfive, rsix, rseven, reight, rnine, rten, releven, rtwelve, rthirt, rfourt, rfift;
int divi, divi2, divi3, divi4, divi5, divi6, divi7, divi8, divi9, divi10, divi11, divi12, divi13, divi14, divi15;

Decimal = JOptionPane.showInputDialog("Enter decimal number");
deci = Integer.parseInt(Decimal);

divi = deci/2;
rone = deci%2;
if (divi == 0){
JOptionPane.showMessageDialog(null, "The binary is: " +rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else {
divi2 = divi/2;
rtwo = divi%2;
if(divi2 == 0){
JOptionPane.showMessageDialog(null, "The binary is: " +rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi3 = divi2/2;
rthree = divi2%2;
if (divi3 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi4 = divi3/2;
rfour = divi3%2;
if (divi4 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else {
divi5 = divi4/2;
rfive = divi4%2;
if (divi5 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi6 = divi5/2;
rsix = divi5%2;
if (divi6 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi7 = divi6/2;
rseven = divi6%2;
if(divi7 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi8 = divi7/2;
reight = divi7%2;
if (divi8 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi9 = divi8/2;
rnine = divi8%2;
if (divi9 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi10 =  divi9/2;
rten = divi9%2;
if (divi10 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi11 =  divi10/2;
releven = divi10%2;
if (divi11 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi12 =  divi11/2;
rtwelve = divi11%2;
if (divi12 ==0){
JOptionPane.showMessageDialog(null, "The binary is: "+rtwelve+""+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone,"result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi13 =  divi12/2;
rthirt = divi12%2;
if(divi13 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rthirt+""+rtwelve+""+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone, "result", JOptionPane.PLAIN_MESSAGE);
}

else{
divi14 =  divi13/2;
rfourt = divi13%2;
if(divi14 == 0){
JOptionPane.showMessageDialog(null, "The binary is: "+rfourt+""+rthirt+""+rtwelve+""+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone, "result", JOptionPane.PLAIN_MESSAGE);
}
else{
divi15 = divi14/2;
rfift = divi14%2;
if(divi15 == 0){
JOptionPane.showMessageDialog(null, "The Binary Number is: "+rfift+""+rfourt+""+rthirt+""+rtwelve+""+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone, "result", JOptionPane.PLAIN_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null, "The Binary Number is: "+rfift+""+rfourt+""+rthirt+""+rtwelve+""+releven+""+rten+""+rnine+""+reight+""+rseven+""+rsix+""+rfive+""+rfour+""+rthree+""+rtwo+""+rone, "result", JOptionPane.PLAIN_MESSAGE);
}}}}}}}}}}}}}}}
}
}

```

Is This A Good Question/Topic? 0

## Replies To: Haha. Laughing at my ultimate longest code ever.

### #2 Martyr2

• Programming Theoretician

Reputation: 5526
• Posts: 14,527
• Joined: 18-April 07

## Re: Haha. Laughing at my ultimate longest code ever.

Posted 27 September 2017 - 12:08 PM

I laughed more at the fact you have so many nested if else statements than its length. As for laughs of length, I just recently found a function that is over 400 lines long in a company's production system. It is doing at least 10 different things.

But anyways, all I have to say about your code is... refactor that \$^#&@!

### #3 Yureeh_30

Reputation: 0
• Posts: 2
• Joined: 27-September 17

## Re: Haha. Laughing at my ultimate longest code ever.

Posted 28 September 2017 - 01:37 AM

Martyr2, on 27 September 2017 - 12:08 PM, said:

I laughed more at the fact you have so many nested if else statements than its length. As for laughs of length, I just recently found a function that is over 400 lines long in a company's production system. It is doing at least 10 different things.

But anyways, all I have to say about your code is... refactor that \$^#&@! />

Haha yeahh😂

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }