Click here to Skip to main content
12,700,567 members (30,236 online)
   

C#

 
GeneralRe: Converting from VB.NET Pin
Andy_L_J18-Nov-12 12:12
memberAndy_L_J18-Nov-12 12:12 
Questionfiltering column value in DevExpress grid view Pin
eli1502197917-Nov-12 21:23
membereli1502197917-Nov-12 21:23 
AnswerRe: filtering column value in DevExpress grid view Pin
n.podbielski17-Nov-12 22:29
membern.podbielski17-Nov-12 22:29 
Questionhelp Pin
AMIR ESLAMI17-Nov-12 10:08
memberAMIR ESLAMI17-Nov-12 10:08 
AnswerRe: help Pin
Eddy Vluggen17-Nov-12 10:25
memberEddy Vluggen17-Nov-12 10:25 
AnswerRe: help Pin
Abhinav S18-Nov-12 21:58
mvpAbhinav S18-Nov-12 21:58 
QuestionAccess to created control Pin
KKW_acd17-Nov-12 6:18
memberKKW_acd17-Nov-12 6:18 
AnswerRe: Access to created control Pin
DaveyM6917-Nov-12 8:30
mentorDaveyM6917-Nov-12 8:30 
QuestionHow do you programatically open a file in c# to append? Pin
Xarzu17-Nov-12 2:05
memberXarzu17-Nov-12 2:05 
AnswerRe: How do you programatically open a file in c# to append? Pin
DaveyM6917-Nov-12 2:35
mentorDaveyM6917-Nov-12 2:35 
AnswerRe: How do you programatically open a file in c# to append? Pin
Eddy Vluggen17-Nov-12 10:32
memberEddy Vluggen17-Nov-12 10:32 
QuestionC# noob: Making Textbox entry a percentage, and Help with loops Pin
maul5916-Nov-12 19:46
membermaul5916-Nov-12 19:46 
AnswerRe: C# noob: Making Textbox entry a percentage, and Help with loops Pin
Richard MacCutchan16-Nov-12 21:43
mvpRichard MacCutchan16-Nov-12 21:43 
AnswerRe: C# noob: Making Textbox entry a percentage, and Help with loops Pin
OriginalGriff16-Nov-12 22:40
mvpOriginalGriff16-Nov-12 22:40 
There are a couple of simple things to do - firstly as Richard said, you need to use floating point values instead of integers:
2 + 30% is 2.6, but as an integer it is 2 again! Laugh | :laugh:

The second is that you are looping through the days, so you don't need to include the number of days in each calculation - just use the result from the previous day.

The third is that when you want an increased value, you can't just multiply by the percentage - 2 * 30% is 0.6, so your increase is 0.6, not your population. To increase your population, multiply but 1.0 + the percentage.

Finally, there is a better way to loop through the days: use a for loop instead of a while:
for (int day = 1; day <= days; day++)
   {
   ... calculate here
   }


So, my version would be:
   resultsListbox.Items.Add(string.Format("The population for day {0} is {1}", day, organisms));
   organisms *= 1.0 + percent;
with percent adjusted to 0.3 as Richard suggested.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

GeneralRe: C# noob: Making Textbox entry a percentage, and Help with loops Pin
maul5916-Nov-12 23:20
membermaul5916-Nov-12 23:20 
GeneralRe: C# noob: Making Textbox entry a percentage, and Help with loops Pin
OriginalGriff16-Nov-12 23:26
mvpOriginalGriff16-Nov-12 23:26 
QuestionInterface issue when implementing Factory pattern Pin
MichCl16-Nov-12 9:36
memberMichCl16-Nov-12 9:36 
AnswerRe: Interface issue when implementing Factory pattern Pin
Eddy Vluggen16-Nov-12 10:01
memberEddy Vluggen16-Nov-12 10:01 
GeneralRe: Interface issue when implementing Factory pattern Pin
MichCl16-Nov-12 10:18
memberMichCl16-Nov-12 10:18 
GeneralRe: Interface issue when implementing Factory pattern Pin
Eddy Vluggen16-Nov-12 14:46
memberEddy Vluggen16-Nov-12 14:46 
GeneralRe: Interface issue when implementing Factory pattern Pin
MichCl19-Nov-12 3:20
memberMichCl19-Nov-12 3:20 
AnswerRe: Interface issue when implementing Factory pattern Pin
Eddy Vluggen19-Nov-12 3:32
memberEddy Vluggen19-Nov-12 3:32 
GeneralRe: Interface issue when implementing Factory pattern Pin
MichCl19-Nov-12 4:51
memberMichCl19-Nov-12 4:51 
GeneralRe: Interface issue when implementing Factory pattern Pin
Eddy Vluggen19-Nov-12 5:46
memberEddy Vluggen19-Nov-12 5:46 
GeneralRe: Interface issue when implementing Factory pattern Pin
MichCl19-Nov-12 10:38
memberMichCl19-Nov-12 10:38 
GeneralRe: Interface issue when implementing Factory pattern Pin
Eddy Vluggen19-Nov-12 10:53
memberEddy Vluggen19-Nov-12 10:53 
QuestionIssue in accessing 32 bit C++ DLL in Windows Server 2008 Pin
Kumaran Poongavanam16-Nov-12 9:32
memberKumaran Poongavanam16-Nov-12 9:32 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 Pin
Eddy Vluggen16-Nov-12 10:04
memberEddy Vluggen16-Nov-12 10:04 
GeneralRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 Pin
Kumaran Poongavanam16-Nov-12 11:09
memberKumaran Poongavanam16-Nov-12 11:09 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 Pin
Dave Kreskowiak16-Nov-12 12:55
mvpDave Kreskowiak16-Nov-12 12:55 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 Pin
jschell17-Nov-12 7:11
memberjschell17-Nov-12 7:11 
QuestionOutlook 2010 / C# - Hide or Remove item from ContextMenuContactItem + add custom item into it Pin
csharpcomeintome16-Nov-12 6:20
membercsharpcomeintome16-Nov-12 6:20 
QuestionException Handling Pin
Phanindra26116-Nov-12 4:21
memberPhanindra26116-Nov-12 4:21 
AnswerRe: Exception Handling Pin
BobJanova16-Nov-12 4:41
memberBobJanova16-Nov-12 4:41 
GeneralRe: Exception Handling Pin
Phanindra26116-Nov-12 9:03
memberPhanindra26116-Nov-12 9:03 
AnswerRe: Exception Handling Pin
Clifford Nelson16-Nov-12 10:49
memberClifford Nelson16-Nov-12 10:49 
GeneralRe: Exception Handling Pin
Dave Kreskowiak16-Nov-12 12:49
mvpDave Kreskowiak16-Nov-12 12:49 
AnswerRe: Exception Handling Pin
Orjan Westin16-Nov-12 5:37
memberOrjan Westin16-Nov-12 5:37 
AnswerRe: Exception Handling Pin
SledgeHammer0116-Nov-12 10:55
memberSledgeHammer0116-Nov-12 10:55 
JokeRe: Exception Handling Pin
Mycroft Holmes16-Nov-12 16:42
memberMycroft Holmes16-Nov-12 16:42 
AnswerRe: Exception Handling Pin
jschell17-Nov-12 7:20
memberjschell17-Nov-12 7:20 
QuestionManual Coding vs Code Generation Pin
Phanindra26116-Nov-12 1:22
memberPhanindra26116-Nov-12 1:22 
AnswerRe: Manual Coding vs Code Generation Pin
DaveyM6916-Nov-12 1:46
mentorDaveyM6916-Nov-12 1:46 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 2:06
membern.podbielski16-Nov-12 2:06 
GeneralRe: Manual Coding vs Code Generation Pin
DaveyM6916-Nov-12 3:37
mentorDaveyM6916-Nov-12 3:37 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 3:47
membern.podbielski16-Nov-12 3:47 
GeneralRe: Manual Coding vs Code Generation Pin
BobJanova16-Nov-12 4:22
memberBobJanova16-Nov-12 4:22 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 4:43
membern.podbielski16-Nov-12 4:43 
AnswerRe: Manual Coding vs Code Generation Pin
Orjan Westin16-Nov-12 3:17
memberOrjan Westin16-Nov-12 3:17 
GeneralRe: Manual Coding vs Code Generation Pin
Phanindra26116-Nov-12 4:09
memberPhanindra26116-Nov-12 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 23 Jan 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid