Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the 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 22nd, 2005, 10:57 PM
Registered User
 
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help me!Who can tell me where is wrong?

I can not debug the following code?Where is wrong?Thanks a lot.
static void Main(string[] args)
        {
            //
            // TODO: add code here
            //
            double balance,interestRate,targetBalance;
            Console.WriteLine("What is your current balance?");
            balance=Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("What is current annual interest rate(in %)?");
            interestRate=1+Convert.ToDouble(Console.ReadLine() )/100.0;
            Console.WriteLine("What balance would you like to have?");
            targetBalance=Convert.ToDouble(Console.ReadLine()) ;

            int totalYears=0;
            do
            {
                balance*=interestRate;
                ++totalYears;
            }
                while(balance<targetBalance);
            Console.WriteLine("In {0} year{1} you'll have a balance of {2}.",totalYears,totalYears=1?"":"s",balance);
        }

 
Old February 23rd, 2005, 10:52 PM
Registered User
 
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

      It can debug by changeing code like this(the last line):Console.WriteLine("In {0} year{1} you'll have a balance of {2}.",totalYears,totalYears!=1?"s":"",balance);
        }


 
Old March 7th, 2005, 06:22 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, right.

DingQiang





Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong ??? FT BOOK: ASP.NET Website Programming Problem-Design-Solution 2 November 3rd, 2005 09:18 AM
Help..What am I doing wrong... Brettvan1 VB.NET 2002/2003 Basics 2 October 18th, 2004 02:36 AM
Where did I go wrong??? ahc2inc VB.NET 2002/2003 Basics 3 September 28th, 2004 08:19 PM
What's wrong?Help! amu BOOK: Beginning ASP.NET 1.0 1 October 28th, 2003 08:21 PM





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