Question

Programming Assignment Practice Concepts ●Registering events ●Protecting inputs through logic Problem Description For PA1, you are...

Programming Assignment

Practice Concepts

●Registering events

●Protecting inputs through logic

Problem Description

For PA1, you are to create a Windows Forms Application using the .NET Framework. Name this

project

LastName_FirstName_PA1

. In this application you will create a tip calculator that takes two

inputs from the user: A Meal Cost value (double), and a Tip Percentage amount (double). The

application should do the following:

1.)

The form text should display the name of your app (i.e. Tip Calculator)

2.)

The form should offer two inputs: one to enter a meal cost value and one to enter a tip

percentage amount. Make sure all inputs are labeled clearly.

3.)

Both inputs should be protected against invalid values (i.e. non-text values, or negative values)

4.)

The form should have a button that initiates the calculation and output of the tip amount. The

tip can be calculated by using the formula: tip = meal cost * percentage in decimal form.

5.)

If the entered tip percentage is less than 1, assume the percentage is already in decimal form.

For example, if the user enters 0.5, this represents 50%.

6.)

If the entered tip percentage is greater than or equal to 1, assume it needs to be converted to

decimal form prior to tip calculation (percentage decimal form = percentage / 100)

Notes: When protecting your inputs, you may use many different ways to inform the user of an invalid

input. You may use a MessageBox, change the color of the form, use additional labels as warnings or

informational outputs, etc. Use your creativity!

Test Conditions

Your program should be free of syntax errors and build and compile properly.

Your program successfully calculates the tip if percentage is entered as decimal form or as

regular percentage form.

Your program informs the user if an invalid input condition exist

Homework Answers

Answer #1

Code

Public Class Form1


Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim cost, per As Decimal
txtTip.Clear()
If (txtCost.Text <> "" And txtTipPer.Text <> "") Then
cost = Convert.ToDecimal(txtCost.Text)
per = Convert.ToDecimal(txtTipPer.Text)
If (cost > 0 And per > 0) Then
txtCost.BackColor = Color.White
txtTipPer.BackColor = Color.White
If (per < 1) Then
txtTip.Text = (cost * per).ToString("C")
Else
txtTip.Text = (cost * per / 100).ToString("C")
End If
Else

If (cost < 0) Then
txtCost.BackColor = Color.Red
End If
If (per < 0) Then
txtTipPer.BackColor = Color.Red
End If
MessageBox.Show("Value can't be negative.")
End If
Else

If (txtCost.Text = "") Then
txtCost.BackColor = Color.Red
End If
If (txtTipPer.Text = "") Then
txtTipPer.BackColor = Color.Red
End If
MessageBox.Show("Value can't be balcnk.")
End If
End Sub
End Class

Form Design

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Know the answer?
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
Similar Questions
For this assignment you'll be creating an application that has the user input a subtotal, tax...
For this assignment you'll be creating an application that has the user input a subtotal, tax rate and tip percentage and then displays the sales tax, tip amount and the total. You'll use JQuery instead of the getElementByX functions AND you will display all messages on the page (no alert or prompt boxes) The starter file is based off of the Lab 2 sales_tax application. Feel free to borrow code from your lab solution but realize you will need to...
You must use Windows Programming(Do NOT use Console) to complete this assignment. Use any C# method...
You must use Windows Programming(Do NOT use Console) to complete this assignment. Use any C# method you already know. Create a Windows application that function like a banking account register. Separate the business logic from the presentation layer. The graphical user interface should allow user to input the account name, number, and balance. Provide TextBox objects for withdrawals and deposits. A button object should be available for clicking to process withdrawal and deposit transactions showing the new balance. Document and...
For this assignment, create an html page that has a login form. The form should have...
For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. This should have a type text for the user to enter UserName 2. This should have a type password (like text except cannot see the text that is typed in), for the user to enter password. 3. Submit button (type submit, as we did in class on 2/6). The form method should be set to POST and the action...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use arrays or vectors. All changes, calculations, etc should be performed in place ( in the file). You may need one or two structures that temporary hold data needed to be displayed, changed, etc. Part 2: Binary Files Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or...
You have decided to volunteer at your local history museum which sells tickets for admission. The...
You have decided to volunteer at your local history museum which sells tickets for admission. The museum curator has asked you to write a program that can help calculate the cost of one ticket for admission to the museum. Children under 6 are admitted for free, while all other children are charged $2.93 per ticket. Adults (18 and over) are charged $8.65 per ticket. All tickets that are not free have a convenience cost of $0.85, and all sales are...
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's profit (or loss) within a certain period of time. 1) First, the program need to get user's name, the stock's code, number of shares and the price he/she purchased the stock, it also asks the user for the price he/she sold the stock later on. The program then compute the following: The amount of money the customer paid for the stock. The amount of...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code and improving its design without changing the functionality. In this programming assignment, you are going to take your code from Programming Assignment 1 and refactor it so that it uses functions. The program should still do the following:  Get the name of a student  Get the name of three assignments  Get the grade of three assignments as integers  Calculates the...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...