|
-
April 29th, 2012, 01:21 PM
#1
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
-
April 29th, 2012, 05:59 PM
#2
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.
-
April 30th, 2012, 10:38 AM
#3
Re: please help me solving this problem
yeah got that .. thanks biophycengr for help 
Regards
Danyal
-
April 30th, 2012, 11:33 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|