someone can help me to find where is the mistake

• 10-22-2011, 01:39 PM
someone can help me to find where is the mistake
when I enter value it gave always is not perfect number

static void perfectn()
{int a;
Scanner cso=new Scanner(System.in);
a=cso.nextInt();
int z,x,y;x=0;
for(z=1;z<=a;z++)
{
if(a%z==0){x=x+z;}
}
if(a==x){System.out.println(a+" is perfect number");}
else System.out.println(a+" is not perfect number");
• 10-22-2011, 01:54 PM
Fubarable
Re: someone can help me to find where is the mistake
Print out the value of x at the end of your method and see if it makes sense by comparing it with what you calculate on paper it should be. With this number you should be able to figure out your bug. Another hint: look at your for loop control statement (the first line that begins for (... ) because that's where your bug is.

um, nice forum name by the way. I think.
• 10-22-2011, 02:49 PM
Re: someone can help me to find where is the mistake
thanks alot there is an = and it doesnt work correctly programming is laughable
are you muslim
• 10-22-2011, 03:13 PM
Fubarable
Re: someone can help me to find where is the mistake
Quote:

thanks alot there is an = and it doesnt work correctly programming is laughable
are you muslim

Good, you saw it. And no, I am Jewish.

Bettawfeeq
• 10-22-2011, 03:20 PM
Re: someone can help me to find where is the mistake
hmm
I have another question
I should write a program that should print leap year in 21.century (2001 to 2102)
these are codes

public class P32 {
public static void main(String[] args)
{ int a,b,c;

for(a=2001;a<2103;++a)
{ if((a%4==0)&&(a%100!=0)||(a%400==0))
System.out.println(a+" ");
}

}

}

what is wrong
• 10-22-2011, 03:35 PM
JosAH
Re: someone can help me to find where is the mistake
Quote:

what is wrong

You tell us the symptoms of what is wrong; we are not going to debug badly indented, badly formatted code for you.

Jos

ps I find your screen name rather stupid.
• 10-22-2011, 04:01 PM
Re: someone can help me to find where is the mistake
actually it is my real name
it is not stupid it has very deep meaning
I cant explain but basicly it means to fight for Allah who create you
but every person has different mind it can be stupid for you

by the way you are so tough if you dont want to help you dont write
why you are acting like that
• 10-22-2011, 04:06 PM
JosAH
Re: someone can help me to find where is the mistake
Quote:

actually it is my real name
it is not stupid it has very deep meaning
I cant explain but basicly it means to fight for Allah who create you
but every person has different mind it can be stupid for you

by the way you are so tough if you dont want to help you dont write
why you are acting like that

Everyone is free to write here; you can't forbid anyone to do so; I can't forbid you to write here and I don't even attempt to do so. The 'deep' meaning of you name is in the eye of the beholder; it isn't 'deep' for me (I don't believe in any god at all b.t.w.) and I find it insulting; it isn't your fault if it is your real name.

Jos
• 10-22-2011, 04:19 PM
Re: someone can help me to find where is the mistake
if you dont believe god I cant explain the perfect side of the name because I dont have enough information it is very religious word .there are maybe millions of book which try to explain meanning of jihad but if you search islam you will see what is jihad and why people are doing jihad
• 10-22-2011, 04:32 PM
JosAH
Re: someone can help me to find where is the mistake
Quote:

if you dont believe god I cant explain the perfect side of the name because I dont have enough information it is very religious word .there are maybe millions of book which try to explain meanning of jihad but if you search islam you will see what is jihad and why people are doing jihad

Many, many bad things have been done in the name of (a) jihad (especially against non-muslim societies) so the name has (at least to me) a very bad connotation.

Jos

ps. discussion closed
• 10-22-2011, 10:12 PM