Question

Create a GUI program (a Windows Forms Application) called GooseEggCalculator that lets a user enter the...

Create a GUI program (a Windows Forms Application) called GooseEggCalculator that lets a user enter the number of eggs produced by each of four geese. Your program should provide textboxes with labels for the user to enter the values. When the user clicks a Calculate button, your app should sum the textboxes, then display the total number of eggs, as well as the number of eggs in dozens and remaining eggs, as shown on the example. Feel free to make your app look nicer than the example GUI shown.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "GooseEggCalculator".This application contains a form with name "Form1.cs".Below are the files associated with form1.

1.Form1.cs[Design]

2.Form1.Designer.cs

namespace GooseEggCalculator
{
partial class Form1
{
/// <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.lblGoose1 = new System.Windows.Forms.Label();
this.txtGeese1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtGeese2 = new System.Windows.Forms.TextBox();
this.txtGeese3 = new System.Windows.Forms.TextBox();
this.txtGeese4 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btnCalculate = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.lblDetails = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblGoose1
//
this.lblGoose1.AutoSize = true;
this.lblGoose1.Location = new System.Drawing.Point(50, 33);
this.lblGoose1.Name = "lblGoose1";
this.lblGoose1.Size = new System.Drawing.Size(89, 13);
this.lblGoose1.TabIndex = 0;
this.lblGoose1.Text = "Eggs for Geese 1";
//
// txtGeese1
//
this.txtGeese1.Location = new System.Drawing.Point(145, 26);
this.txtGeese1.Name = "txtGeese1";
this.txtGeese1.Size = new System.Drawing.Size(100, 20);
this.txtGeese1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(50, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Eggs for Geese 2";
//
// txtGeese2
//
this.txtGeese2.Location = new System.Drawing.Point(145, 73);
this.txtGeese2.Name = "txtGeese2";
this.txtGeese2.Size = new System.Drawing.Size(100, 20);
this.txtGeese2.TabIndex = 3;
//
// txtGeese3
//
this.txtGeese3.Location = new System.Drawing.Point(145, 122);
this.txtGeese3.Name = "txtGeese3";
this.txtGeese3.Size = new System.Drawing.Size(100, 20);
this.txtGeese3.TabIndex = 4;
//
// txtGeese4
//
this.txtGeese4.Location = new System.Drawing.Point(145, 169);
this.txtGeese4.Name = "txtGeese4";
this.txtGeese4.Size = new System.Drawing.Size(100, 20);
this.txtGeese4.TabIndex = 5;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(50, 129);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(89, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Eggs for Geese 3";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(50, 176);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(89, 13);
this.label3.TabIndex = 7;
this.label3.Text = "Eggs for Geese 4";
//
// btnCalculate
//
this.btnCalculate.Location = new System.Drawing.Point(53, 218);
this.btnCalculate.Name = "btnCalculate";
this.btnCalculate.Size = new System.Drawing.Size(86, 31);
this.btnCalculate.TabIndex = 8;
this.btnCalculate.Text = "&Calculate";
this.btnCalculate.UseVisualStyleBackColor = true;
this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(159, 218);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(86, 31);
this.btnExit.TabIndex = 9;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// lblDetails
//
this.lblDetails.AutoSize = true;
this.lblDetails.Location = new System.Drawing.Point(28, 282);
this.lblDetails.Name = "lblDetails";
this.lblDetails.Size = new System.Drawing.Size(0, 13);
this.lblDetails.TabIndex = 10;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.InactiveCaption;
this.ClientSize = new System.Drawing.Size(294, 334);
this.Controls.Add(this.lblDetails);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnCalculate);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtGeese4);
this.Controls.Add(this.txtGeese3);
this.Controls.Add(this.txtGeese2);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtGeese1);
this.Controls.Add(this.lblGoose1);
this.Name = "Form1";
this.Text = "Goose Egg Calculator ";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lblGoose1;
private System.Windows.Forms.TextBox txtGeese1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtGeese2;
private System.Windows.Forms.TextBox txtGeese3;
private System.Windows.Forms.TextBox txtGeese4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnCalculate;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label lblDetails;
}
}

3.Form1.cs

//namespace
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;
//application namespace
namespace GooseEggCalculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Calculate button click
private void btnCalculate_Click(object sender, EventArgs e)
{
//variable to store sum
int sum = int.Parse(txtGeese1.Text) + int.Parse(txtGeese2.Text) + int.Parse(txtGeese3.Text) + int.Parse(txtGeese4.Text);
//eggs in dozons
int dozons = sum / 12;
//remaining eggs
int rEggs = sum % 12;
//display details
lblDetails.Text = "Total number of Eggs :" + sum + Environment.NewLine + "Number of Eggs in dozens : " + dozons + Environment.NewLine + "Remaining eggs : " + rEggs;
}
//Exit button click
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit(); //close appliction
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Screen 2 :Enter eggs and show the details

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Create a GUI program (a Windows Forms Application) called GooseEggCalculator that lets a user enter the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A fitness tracking app company has asked you to develop a windows application using a GUI...

    A fitness tracking app company has asked you to develop a windows application using a GUI to determine the total amount of hours somebody has exercised during their lifetime, assuming on average a user has exercises 2.5 hours per week. When the user uses the app, they will enter the following: First Name: Last Name: Date of Birth (in mm/dd/yyyy): Current Date (in mm/dd/yyyy) This program should display the users name and the number of hours the user has exercised...

  • Using JavaFX create a Roll application that implements the GUI shown When the user clicks the Rol...

    Using JavaFX create a Roll application that implements the GUI shown When the user clicks the Roll button, the program must roll the dice, change the figures randomly, calculate the sum of the dice and show it in a label

  • Please help! Visual Basic - Windows App Form .NET Framework. ​Option Explicit ON ​Option Strict ON...

    Please help! Visual Basic - Windows App Form .NET Framework. ​Option Explicit ON ​Option Strict ON ​Option Infer ON calculate Letter Grade Number grade: I Letter grade: Calculate Exxt Start a new Project named GradeConverter Add labels, textboxes, and button to the default form. Create an event handler for Calculate and Exit. . When the user enters a number- between 0.0 and 100.0 and clicks Calculate, the letter grade will display for the user The form should be able to...

  • Need help on following Java GUI problem: Write a program that lets a user display and...

    Need help on following Java GUI problem: Write a program that lets a user display and modify pictures. Create a window. Add four buttons so that clicking a particular button will shift the image by a small amount in the north, south, east or west direction inside the window. Add a menu bar with two menus: File and Image. The File menu should contain an Open menu item that the user can select to display JPEG and PNG files from...

  • Develop a Windows Forms application that will allow a user to select between the 5 different...

    Develop a Windows Forms application that will allow a user to select between the 5 different soring algorithms. • The application’s GUI should include / perform the following: o A textbox to enter a string value o A button to submit the string value o A listbox to store all of the submitted string values. The entries in this list will always be unsorted, i.e. it should list the entries in the sequence in which they have been captured. o...

  • This is python3. Please help me out. Develop the following GUI interface to allow the user...

    This is python3. Please help me out. Develop the following GUI interface to allow the user to specify the number of rows and number of columns of cards to be shown to the user. Show default values 2 and 2 for number of rows and number of columns. The buttons "New Game" and "Turn Over" span two column-cells each. Fig 1. The GUI when the program first starts. When the user clicks the "New Game" button, the program will read...

  • Create a C# Form with a textbox and a button. The box is for a user...

    Create a C# Form with a textbox and a button. The box is for a user to enter a number of seconds. And when the user clicks the button, the program displays the equivalent number of hours, minutes and seconds using a MessageBox. Show method. If the seconds entered is less than 60, your program should only display the seconds; if the seconds is a least 60 and less than 3600, your program should display minutes and seconds; if the...

  • Create a Roll application that implements the GUI shown in figure 1 (default images must be...

    Create a Roll application that implements the GUI shown in figure 1 (default images must be set as shown in figure 1). When the user clicks the Roll button, the program must roll the dice, change the figures randomly, calculate the sum of the dice and show it in a label (as shown in figure 2).

  • For this question you will need to complete the methods to create a JavaFX GUI application...

    For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT