Wrox Programmer Forums
|
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
 
Old February 18th, 2004, 10:10 AM
cyj cyj is offline
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cyj Send a message via Yahoo to cyj
Default help!

who have the answer of chapter4 Q4?
thanks a lot!

 
Old February 18th, 2004, 01:32 PM
Authorized User
 
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Chris Beach Send a message via AIM to Chris Beach Send a message via MSN to Chris Beach Send a message via Yahoo to Chris Beach
Default

For Q2 I've Got
Code:
namespace Ch04Q02
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            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);

            Console.WriteLine("Sum of ints<10? {0}", (myInt1 + myInt2) < 10);
            Console.WriteLine("Sum of ints between 0 and 5? {0}", 
                (0 <= myInt1 + myInt2) && (myInt1 + myInt2 <= 5));
            Console.WriteLine("Bitwise AND of int sum and 10 = {0}", myInt1 + myInt2 & 10);
        }
    }
}
And for Q4 I've got
Code:
using System;

namespace Ch04Q04
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            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)
                {
                    iterations=0;
                    realTemp=realCoord;
                    imagTemp=imagCoord;
                    arg=(realCoord*realCoord)+(imagCoord*imagCoord);
                    while((arg<4)&&(iterations<40))
                    {
                        realTemp2=(realTemp*realTemp)-(imagTemp*imagTemp)-realCoord;
                        imagTemp=(2*realTemp*imagTemp)-imagCoord;
                        realTemp=realTemp2;
                        arg=(realTemp*realTemp)+(imagTemp*imagTemp);
                        iterations+=1;
                    }
                    switch (iterations %4)
                    {
                        case 0:
                            Console.Write(".");
                            break;
                        case 1:
                            Console.Write("o");
                            break;
                        case 2:
                            Console.Write("O");
                            break;
                        case 3:
                            Console.Write("x");
                            break;
                    }
                }
                Console.Write("\n");
            }
            Console.ReadLine();
        }
    }
}
 
Old February 19th, 2004, 09:49 AM
cyj cyj is offline
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cyj Send a message via Yahoo to cyj
Default

anyway thank you very much! ^_^










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.