 |
BOOK: Beginning Visual C#  | This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 17th, 2003, 11:27 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 4 Exercises
Just wanted to double check my answers. Any help would be appreciated.
1.) ^
2.)
static void Main(string[] args)
{
int firstInt, secondInt;
Console.WriteLine("Please enter 2 integers where the sum of the 2 are less then or equal to 10:");
do
{
firstInt = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Now enter another integer:");
secondInt = Convert.ToInt32(Console.ReadLine());
if (10 <= firstInt + secondInt)
Console.WriteLine("Both numbers must be less then 10!\nPlease enter you first number again.");
}
while (10 <= firstInt + secondInt);
Console.WriteLine("Sum of both Int less then 10? {0}", firstInt + secondInt < 10);
Console.WriteLine("Integers between 0 and 5? {0}",
(0 <= firstInt + secondInt) && (firstInt + secondInt <= 5));
Console.WriteLine("Bitwise AND of Integers and 10 = {0}", firstInt + secondInt & 10);
}
3.) just a = will not get boolean comparison, and will just set i = 0 and will error out or loop forever.
4.) I didn't spend to much time trying to understand the Mandelbrot forumal so I couldn't/didn't want to do this one =P If anyone wants to post what they did and explain it that would be great :D
|
|

August 18th, 2003, 07:08 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
1) XOR
2) reading the q differently I think cause I've got:
Code:
int myInt1,myInt2;
Console.WriteLine("Please enter an integer:");
do
{
myInt1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Now enter another integer:");
myInt2 = Convert.ToInt32(Console.ReadLine());
if (myInt1>10 && myInt2>10)
Console.WriteLine("Both numbers must be less then 10!\nPlease enter you first number again.");
}
while (myInt1>10 && myInt2>10);
ie if both numbers entered are >10 then get them again, so (1,2),(12,2) is ok but (12,11) isn't
|
|

August 18th, 2003, 07:23 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
As for 4 well the first half:
Code:
double realCoord, imagCoord;
double realTemp, imagTemp, realTemp2, arg;
double realMin=-0.6,realMax=1.77,imagMin=-1.2,imagMax=1.2; //limits
//get limits
Console.WriteLine("Please enter the min Real coord {0}:",realMin);
realMin=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the max Real coord {0}:",realMax);
realMax=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the min Imaginary coord {0}:",imagMin);
imagMin=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the max Imaginary coord {0}:",imagMax);
imagMax=Convert.ToDouble(Console.ReadLine());
int iterations;
for (imagCoord=imagMax;imagCoord>=imagMin;imagCoord-=0.05)
{
for (realCoord=realMin; realCoord<=realMax;realCoord+=0.03)
{
...
For the second half I think we need to alter the increments of the loops...working on that now.
|
|

August 18th, 2003, 07:48 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok it is the increments, first I worked out the ratio between the cords and the current increment, for the real it was 79 and for the imaginary part it was 48...so the code now looks like:
Code:
double realCoord, imagCoord;
double realTemp, imagTemp, realTemp2, arg;
double realMin=-0.6,realMax=1.77,imagMin=-1.2,imagMax=1.2; //limits
double realInc=0.03,imagInc=0.05; //increments
//get limits
Console.WriteLine("Please enter the min Real coord {0}:",realMin);
realMin=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the max Real coord {0}:",realMax);
realMax=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the min Imaginary coord {0}:",imagMin);
imagMin=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the max Imaginary coord {0}:",imagMax);
imagMax=Convert.ToDouble(Console.ReadLine());
//work out inc's
imagInc=(imagMax-imagMin)/48;
realInc=(realMax-realMin)/78; //uh why not 79??
int iterations;
for (imagCoord=imagMax;imagCoord>=imagMin;imagCoord-=imagInc)
{
for (realCoord=realMin; realCoord<=realMax;realCoord+=realInc)
...
god knows why you need to change 79 to 78 but if you don't you get a gap between the lines...
|
|

August 20th, 2003, 11:37 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the response. Yea on #2 I had something similiar to that to before, but rereading the question I thought it wanted the sum of both #'s not to be greater then 10. But I could be wrong the question is a bit vague on that.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Chapter 2 - End of chapter exercises |
whizzkid1892 |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
1 |
July 30th, 2008 12:02 PM |
|
 |