|
thanx , you both cleaned my perspective with those abstract concepts ! Jarno Burger
Video Jockey
|
|
|
|
|
i want to write a program.
i want to enter a number in between 4000 and 8000 and this number should contain the digit "2" in any place.eg:4002,4213,5002
please provide the complete coding.As iam a beginner,i consulted many people, but didn't get the answer.
|
|
|
|
|
ajay 2010 wrote: i consulted many people
Exactly how many times are you going to ask the same question without even bothering to try and do it yourself?Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
i have tried it. but i failed. that's why asked for help.i tried in this way..
int[] ajay=new int[3];
int x;
Console.WriteLine("enter the number");]
x=Convert.Int32(Console.Readline());
if ((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)
{
Console.writeline("valid");
}
else
{
Console.writeline("invalid");
}
|
|
|
|
|
ajay 2010 wrote: i tried in this way
You would have saved yourself a lot of trouble if you had just said so to begin with.
The first thing is that you have declared ajay as an array of ints with three elements and then later on trying to access the 4th element (ajay[3]). Which will always fail.
The second thing is that ajay doesn't contain anything since you never assigned anything to it. ajay[0] = 0, ajay[1] = 0, etc.
The third thing is that you are going about it too hard. Cast the int to a string and then see if "2" is in the string:
if (x.ToString().Contains("2"))
The last thing is that your question sounds suspiciously like homework and I am not entirely sure that it is not homework. If it is then you have a long hard road ahead of you. You are not likely going to succeed demanding that we provide code to you.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
thanks for your reply.
This is not a homework. This is one interview question they asked during one freshers interview.
|
|
|
|
|
Thanks dear..
i solved the problem, here it is....
int[] ajay=new int[4];
ajay[0]=2;
ajay[1]=2;
ajay[2]=2;
ajay[3]=2;
int x;
Console.WriteLine("enter the number");
x=Convert.ToInt32(Console.ReadLine());
x=x+1;
if (((x>4000)&&(x<8000))&&((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)))
{
Console.WriteLine("valid");
}
else
{
Console.WriteLine("invalid");
}
Anyway i didn't understand the usage of "contains"...i tried a lot..its not available...iam using .net 2003...
Anyway thanks for the information you provided in the previous e-mail,it helped me a lot to get the desired result...now i am happy...
|
|
|
|
|
Tell you what, you post us the code you have so far and we'll try and point you in the right direction. You can't just ask people to give you the coding, if you're a beginner, you're meant to be learning, so LEARN!
If you post questions that look and smell like homework, then keep asking them when you don't get answers, you're just going to lose the respect of other members. You need to at least prove you can do some of the work and eventually, through learning get to your answer.
|
|
|
|
|
i have tried it. but i failed. that's why asked for help.i tried in this way.
int[] ajay=new int[3];
int x;
Console.WriteLine("enter the number");]
x=Convert.Int32(Console.Readline());
if ((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)
{
Console.writeline("valid");
}
else
{
Console.writeline("invalid");
}
|
|
|
|
|
Posting the same code over and over again in response isn't going to get people to take pity on you and post the answer.
You're populating x but checking ajay, at what point do you populate ajay with the value you entered in x?
|
|
|
|
|
i replied to everyone who r all send a response(good or bad response). that's all..i don't want anyone's pity or sympathy..
when some people ask some doubt, if you can solve it..otherwise keep your mouth shut..at least that you people can do...right..
anyway thanks for your response and the information you given...
i myself wrote the program...
int[] ajay=new int[4];
ajay[0]=2;
ajay[1]=2;
ajay[2]=2;
ajay[3]=2;
int x;
Console.WriteLine("enter the number");
x=Convert.ToInt32(Console.ReadLine());
x=x+1;
if (((x>4000)&&(x<8000))&&((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)))
{
Console.WriteLine("valid");
}
else
{
Console.WriteLine("invalid");
}
thanks for everyone.Don't feel bad, if i hurt you...consider everyone like your younger brother,then you won't feel like to scold...
|
|
|
|
|
ajay 2010 wrote: i want to write a program.
ajay 2010 wrote: please provide the complete coding
Does anything strike you as conflicting between these two desires?
You have posted 6 times on this site, all related to the same question. Either do some of it yourself, and get stuck - then ask for help with the bit you are stuck on, or give up the course and go home. Because if you don't do anything yourself, you are never going to pass anyway.If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
His nickname and questions bare a striking resemblance with those of jojoba2010's
|
|
|
|
|
I don't think so - his questions are much more basic than jojoba's. He was annoying and talentless, but he had some education. A bit too much perhaps...certainly for his ability level. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
I agree. But I remember one of jojoba's question:
He Had and error(compiling error) that said something like this: "Add() is deprecated. Use AddWithValue()" and he posted a question twice on how to fix it!
|
|
|
|
|
i have tried it. but i failed. that's why asked for help.i tried in this way
int[] ajay=new int[3];
int x;
Console.WriteLine("enter the number");]
x=Convert.Int32(Console.Readline());
if ((ajay[0]==2)||(ajay[1]==2)||(ajay[2]==2)||(ajay[3]==2)
{
Console.writeline("valid");
}
else
{
Console.writeline("invalid");
}
|
|
|
|
|
Here's some pseudocode you can start with:
string input = getInput();
if ((IsNumber(input) && InputContains("2"))
JumpUpAndDownWithJoy();
else
CryTearsAndScreamDisappointment(); CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Walt Fair, Jr. wrote: CryTearsAndScreamDisappointment()
How did I miss that one in MSDN? If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
It's an obscure method in ISissyGirl
|
|
|
|
|
That explains it - I've never used the ISissyGirl interface (I tend to stick with ICryBaby) If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
ajay 2010 wrote:
i want to enter a number in between 4000 and 8000 and this number should contain the digit "2
I'm so excited for you. It's almost sexual this feeling. What are you doing later on? Your towering intellect is a real turn on. Oh no - I got wood."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: I got wood
More likely: woods[^] and too much mushrooms. Again.
BTW: here[^] is a useful application for it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Friday, February 12, 2010 3:54 PM
|
|
|
|
|
Pete O'Hanlon wrote: I got wood
Be careful Pete, he might just try and track you down....Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Pete O'Hanlon wrote: I'm so excited for you. It's almost sexual this feeling.
ROTFL x 1000000! Has he taken you up on your offer?Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
public void codez(int CodingNumber)
{
if (CodingNumber <= 8000)
{
throw new Exception("No");
}
if (CodingNumber == 4000)
{
throw new Exception("No");
}
if(CodingNumber == 4001)
{
throw new Exception("No");
}
if(CodingNumber == 4002)
{
return;
}
if (CodingNumber == 8000)
{
throw new Exception("No");
}
if (CodingNumber >= 8000)
{
throw new Exception("No");
}
}
The above code will work if you fill in the blank in the middle. Of course the code is abhorrent to anyone with eyes, but hopefully it will stop you from asking us to do your homework for you again. I could have done this on my Sinclair Spectrum, aged 10 years old in about ten minutes, so I fail to see why you haven't yet made an attempt to do this in the time you have repeatedly posted this question.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|