Question

Programming question. Using Visual Studio 2019 C#. Windows Forms Application. Write the code to display the message “Entry error” in the msgLabel when the value in the Integer units variable is less t...

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

Write the code to display the message “Entry error” in the msgLabel when the value in the Integer units variable is less than or equal to 0. Otherwise, calculate the total owed as follows: If the value stored in the units variable is less than 20, multiply the value by $10; otherwise, multiply it by $5. Store the total owed in the total variable.

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 "demoForm.cs".Below are the files associated with form1.

1.demoForm.cs[Design]

Value for Total VariableX Enter value for Units Calculate

2.demoForm.Designer.cs

3.demoForm.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 demoForm : Form
{
public demoForm()
{
InitializeComponent();
}
//Calculate button click
private void btnCalculate_Click(object sender, EventArgs e)
{
//taking value of units
int units = int.Parse(txtUnits.Text);
//declaring variale total
int total = 0;
//checking value of units
if(units>0)
{
//checking value of units variable
if(units < 20)
{
//calculate total
total = units * 10;//multiply by 10
}
else
{
//calculate total
total = units * 5;//multiply by 5
}
//display total
msgLabel.Text = "Total : " + total;
}
else
{
//display error on the lable
msgLabel.Text = "Entry error";
}

}
}
}

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

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

Screen 1 :

Value for Total VariableX Enter value for Units Calculate

Screen 2 :Screen when units are <=0

Value for Total Variable-X Enter value for Units Calculate Entry error

Screen 3 :Screen when units are < 20

Value for Total Variable - Enter value for Units 15 Calculate Total 150

Screen 4 :Screen when units are > 20

Value for Total Variable - Enter value for Units Calculate Total 110

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 to display the message “Entry error” in the msgLabel when the value in the Integer units variable is less t...
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
  • 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.

  • Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for...

    Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for program with ALL conditions met. Conditions to be met: Word Problem A person inherits a large amount of money. The person wants to invest it. He also has to withdraw it annually. How many years will it take him/her to spend all of the investment that earns at a 7% annual interest rate? Note that he/she needs to withdraw $40,000.00 a year. Also there...

  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

  • THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost...

    THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost of donuts at your local Rich Horton’s store. The cost, of course, depends on the number of donuts you purchase. The following table gives the break down: Donuts Purchased Cost per Donut ($) = 15 0.75 A customer can save on the HST (13%) if they buy 12 or more donuts so only charge HST (use a constant) on the purchase if the customer...

  • 2.)Which character is used to denote a comment? A.) # B.) \ C.) % D.) '...

    2.)Which character is used to denote a comment? A.) # B.) \ C.) % D.) ' 3.)Which of these tasks is impacted by both Option Strict and Option Explicit? A.) Declaring a variable B.) Masking C.) Interpreting an event D.) Casting a variable at some point after it has been declared​ 4.) What happens when you type a line such as this: variable *=5 A.) Multiply the current value of the variable by 5 and store it as variable B.)...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

  • This is a standard C++ programming assignment using a command line g++ compiler or the embedded...

    This is a standard C++ programming assignment using a command line g++ compiler or the embedded one in zyBooks. No GUI forms and no Visual Studio. No external files and no databases are used. There is only one object-oriented program to complete in this assignment. All code should be saved in a file named ExamScoresUpdate.cpp, which is the only file to submit for grading. No .h files used. The .cpp file contains main() and two classes, ExamScores and DataCollector. There...

  • ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following...

    ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following two problems. Upload your source code files to Canvas. The file names must be of the form coins_your_name.cpp and bonus_your_name.cpp for problems 1 and 2, respectively. Substitute your first and last name for "your_name" in the file name. Problem Statements 1. Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Please write c++ (windows) in simple way and show all the steps with the required output

    please write c++ (windows) in simple way and show all the steps with the required output Write a C++ program that simulates the operation of a simple online banking system The program starts by displaying its main menu as shown in Figure1 splay Account nformatson verity Your credit Card elect vour choice Figure 1 Main menu of the program The menu is composed of the following choices 1. When choice 1 is selected (Display Account information), the program should display...

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