Question

In: Computer Science

In C# Create a windows application which accepts the month number and displays the month name...

In C# Create a windows application which accepts the month number and displays the month name in a label.  

Use a nested if... else statement to determine the month name.

For months not in the range 1-12 display the message "Not a valid month"

Solutions

Expert Solution

Answer:

Note: Please rename form component as displayed in screenshot

Code:

using System;
using System.Windows.Forms;

using System;
using System.Windows.Forms;
namespace MonthName
{
public partial class Month : Form
{
public Month()
{
InitializeComponent();
}
private void btnDisplay_Click(object sender, EventArgs e)
{
//convert text into number
int num = Convert.ToInt32(txtNum.Text);
if(num == 1)//check for number
lblmonth.Text="January"; //Display month name   
else if (num == 2)
lblmonth.Text = "February";
else if (num == 3)
lblmonth.Text = "March";   
else if (num == 4)
lblmonth.Text = "April";
else if (num == 5)
lblmonth.Text = "May";
else if (num == 6)
lblmonth.Text = "June";
else if (num == 7)
lblmonth.Text = "July";
else if (num == 8)   
lblmonth.Text = "August";   
else if (num == 9)
lblmonth.Text = "September";   
else if (num == 10)
lblmonth.Text = "October";
else if (num == 11)   
lblmonth.Text = "November";
else if (num == 12)
lblmonth.Text = "December";
else //number is not from 1 to 12
lblmonth.Text = "Not a valid month";
}
}
}

Screenshot:


Related Solutions

Create a C# Windows Console application that displays the following patterns separately, one after the other....
Create a C# Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and...
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...
Create a GUI application in C# that calculates and displays the total travel expenses of a...
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 taxi charges, if any • Conference or seminar...
***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...
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
Create a Windows application in C# that can be used to change the form color. Your...
Create a Windows application in C# that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the...
Create a windows form application in C# that looks and functions like a basic calculator. It...
Create a windows form application in C# that looks and functions like a basic calculator. It must do the following: Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with...
C++ ONLY WITH COMMENTS Question: Producer / Consumer Create a program where the application accepts 2...
C++ ONLY WITH COMMENTS Question: Producer / Consumer Create a program where the application accepts 2 arguments form the command line. The first one is a number where it is a producer of threads and the second one is number of consumer threads. You are allowed to use vector as a buffer and if so then please consider it as the buffer infinite. The producers will create the widgets and will put them on the buffer however the consumer will...
How to make an application for windows using c# ?
How to make an application for windows using c# ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT