Question

In: Computer Science

Create in C Sharp : Create an application that predicts the approximate size of a population...

Create in C Sharp : Create an application that predicts the approximate size of a population of organisms. The application should use text boxes to allow the user to enter the starting number of organisms, the average daily population increase (as a percentage), and the number of days the organisms will be left to multiply. For example, assume the user enters the following values in text boxes:

Starting number of organisms: 2

Average daily increase: 30%

Number of days to multiply: 10

Hint: (new number) = (old number) * (1 + rate/100)

When the user clicks on a button, the application should use a ListBox control to display the data

using a for loop instead of a while loop

Solutions

Expert Solution

SOLUTION-
I have solve the problem in C# code with comments and screenshot for easy understanding :)


Note: I have developed this application according to your given formulae. But I think the formulae is wrong. you didn't use a number of days .Anyhow, I developed it.simply replace your new formulae otherwise leave a comment with updated formula.

CODE-

Designing code: Form2.Design.cs

namespace WindowsFormsApplication2
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(41, 41);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(143, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Starting number of organisms";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(208, 38);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(136, 20);
this.textBox1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(56, 79);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Average daily increase(%)";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(54, 117);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(130, 13);
this.label3.TabIndex = 0;
this.label3.Text = "Number of days to multiply";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(208, 114);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(136, 20);
this.textBox2.TabIndex = 1;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(208, 76);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(136, 20);
this.textBox3.TabIndex = 1;
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(153, 157);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(110, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Population Size";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(137, 203);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(136, 160);
this.listBox1.TabIndex = 3;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(484, 391);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1;
}
}

c# code:Form2.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int oldNumber;
if (listBox1.Items.Count > 0)
{
oldNumber = Convert.ToInt32(listBox1.Items[0].ToString());
}
else
{
oldNumber = Convert.ToInt32(textBox1.Text.Trim());
}

int newNumber = oldNumber * (1 + (Convert.ToInt32(textBox3.Text.Trim()) / 100));

listBox1.Items.Clear();
listBox1.Items.Insert(0, newNumber);
}
}
}

Output:


IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------


Related Solutions

Create a simple C++ application that will exhibit concurrencyconcepts. Your application should create two threads...
Create a simple C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0. For your created code, provide a detailed analysis of appropriate concepts that could impact your application. Specifically, address:Performance issues with concurrencyVulnerabilities exhibited with use of stringsSecurity of the data types exhibited.
Assuming the population has an approximate normal distribution, if a sample size n = 24 has...
Assuming the population has an approximate normal distribution, if a sample size n = 24 has a sample mean ¯ x = 49 with a sample standard deviation s = 2 , find the margin of error at a 99% confidence level. THEN YOU MUST ROUND TO TWO DECIMALS..
JAVAFX Create a JavaFx application that is an MP3 player. The size of the media player...
JAVAFX Create a JavaFx application that is an MP3 player. The size of the media player should be 800 pixels in width and 650 pixels in height. The media player should have a TextField that allows the user to type the full path of the .mp3 file to be played. The application should also use 2 Checkbox controls to show/hide the total playing time and the status (methods of MediaPlayer class). Use 2 RadioButton controls to change background colors (red...
Assuming the population has an approximate normal distribution, if a sample size n=10 has a sample...
Assuming the population has an approximate normal distribution, if a sample size n=10 has a sample mean ¯x=36 with a sample standard deviation s=9, find the margin of error at a 90% confidence level. THEN YOU MUST ROUND ANSWER TO TWO DECIMALS PLACES.
Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
C++Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.
Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
C++ application:Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.For your created code, provide a written analysis of appropriate concepts that could impact your application.Please Specifically, Address: Performance Issues with Concurrency Vulnerabilities Exhibited with use of Strings and Security of the Data Types used.
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
In C# Create a GUI application that calculates and displays the total travel expenses of a...
In C# Create a GUI application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: Number of days on the trip Amount of airfare, if any Amount of car rental fees, if any Number of miles driven, if a private vehicle was used Amount of parking fees, if any Amount of taxi charges, if any Conference or seminar registration fees, if any Lodging charges, per...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT