Question

Programming question. Using Visual Studio 2019 C#. Windows Forms Application. Write the code that assigns the...

Programming question. Using Visual Studio 2019 C#. Windows Forms Application.

Write the code that assigns the number 15 to the reward variable when the state variable contains the string “IL” (entered using any case) and the sales variable contains a number that is greater than 2000; otherwise, assign the number 5.

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 with name "DemoWindowsForms".This application contains a form with name "Form1.cs".Below are the files associated with form1.

1.Form1.cs[Design]

2.Form1.Designer.cs

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 DemoWindowsForms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//display button click
private void btnDisplay_Click(object sender, EventArgs e)
{
//taking value of state variable
string state = txtState.Text;
//taking value of sale variable
int sale = int.Parse(txtSale.Text);
//declaring variable
int reward = 0;
//checking value of state and sale variables
if(state.ToLower()=="il" && sale > 2000)
{
//set value for reward variable
reward = 15;
}
else
{
reward = 5;
}
//display value of reward
lblResult.Text = "Reward : " + reward.ToString();
}
}
}

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

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

Screen 1 :

Screen 2 :Screen when reward="IL " and sale > 2000

Screen 3 :Screen when reward is not IL or sale < 2000

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

Add a comment
Know the answer?
Add Answer to:
Programming question. Using Visual Studio 2019 C#. Windows Forms Application. Write the code that assigns 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
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