CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Lightbulb please help me solving this problem

    i m new to Programming. Please help me solving this Question .. thanks .. i m doing this like ... having some logical error

    Assuming the ocean’s level is currently rising at about 1.5 millimeters per year; write a program that displays a table
    showing the number of millimeters that the ocean will have risen each year for the next 25 years.


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                double rate = 1.55;
                for (double year = 1; year <= 25; year++)
                {
                
                    rate = rate * year;
    
                    Console.WriteLine(rate);
                    
                }
    
                
                    
            }
        }
    }
    Last edited by BioPhysEngr; April 29th, 2012 at 05:59 PM. Reason: code tags

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: please help me solving this problem

    Hi, welcome to the forum.

    First, please use [code] and [/code] tags to keep your source code formatted and easy to read (I have fixed your initial submission).

    Second, the problem is that the prompt says the rate is constant, yet you modify the value of rate with every iteration through the loop. What you want to compute is the total amount of increase which is given by the formula:

    Risen = Rate * Years

    Do you see how to implement this?
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    Re: please help me solving this problem

    yeah got that .. thanks biophycengr for help

    Regards

    Danyal

  4. #4
    Join Date
    Mar 2012
    Location
    Nigeria
    Posts
    15

    Re: please help me solving this problem

    Nice contribution @ BioPhysEngr.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured