Concept explainers
Calculator Write a
Implementation of a program to create a calculator which performs addition, subtraction, and multiplication.
Program Plan:
Write a program which creates a calculator having two input text boxes in which the numbers are entered by the user.
The user can click on any of the three buttons of addition, subtraction, and multiplication.
Whichever button is clicked, it’s result will be calculated and displayed on the output textbox.
Program Description:
The program works for the creation of a calculator which adds, subtracts, or multiplies the two numbers entered by the user in two separate textboxes and displays the calculation in the output textbox.
There are two textboxes which take input from the user for the first number and the second number.
Three buttons, one for addition, second for subtraction, and the third for multiplication are created.
On clicking the respective buttons, the output textbox will display the calculation.
Explanation of Solution
Program:
Public Class Calculator
'Declare variable.
Dim var2 As Integer
'Declare variable.
Dim var1 As Integer
'Declare variable.
Dim result As Integer
'Create the event for the textbox.
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
'Assign value
var1 = TextBox1.Text
'Assign text to the textbox.
TextBox3.Text = var1
'Ending the function
End Sub
'Create text box event.
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
'Assign text to the textbox.
var2 = TextBox2.Text
End Sub
'Create a button click event
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
result = var1 + var2
'Assign text to the textbox.
TextBox3.Text = var1 & "+" & var2 & "=" & result
End Sub
'Create a button click evetn
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
result = var1 - var2
'Assign text to the textbox.
TextBox3.Text = var1 & "-" & var2 & "=" & result
End Sub
'Create a button click event
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
result = var1 * var2
'Assign text to the textbox.
TextBox3.Text = var1 & "*" & var2 & "=" & result
End Sub
End Class
On pressing the addition button:
On pressing the subtraction button:
On pressing the multiplication button:
Want to see more full solutions like this?
Chapter 3 Solutions
Introduction to Programming Using Visual Basic (10th Edition)
Additional Engineering Textbook Solutions
C Programming Language
Starting Out With Visual Basic (8th Edition)
Absolute Java (6th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Concepts of Programming Languages (11th Edition)
- 4-5 A Girl Scout needs to calculate the total dollar amount of her cookie orders. User input should be used to find the quantities sold of Smores, Thin Mints, Caramel DeLites, Shortbread, and Peanut Butter Patties. Use a selling price of $5 per box for Smores and Caramel DeLites, $4 per box for Thin Mints and Peanut Butter Patties, and $3 per box for Shortbread cookies. Print the total number of boxes sold, the total revenue for each flavor, and the total amount collected for all cookies. Use the main function and a function to calculate the sales. python 3 or above please.arrow_forwardSentence Statistics Create a program that can tell a user how many times a particular character appears in text input. Your program will analyze the input, then prompt the user to enter characters to get stats. When the user types 'Q' the program will exit. Enter text input to analyze: The quick brown fox jumped over the lazy dog. What character do you want stats on? a The character a appears 1 times. What character do you want stats on? e The character e appears 4 times. What character do you want stats on? z The character z appears 1 times. What character do you want stats on? Q Goodbye! Analyzing the sentence We've provided starter code in main.cc to get input from the user. Now you need to analyze it. You can use a std::map to store information about each character and the number of times it appears in the input. A std::map maps keys of one type to values of another type. For this problem, you'll want to map from a letter to the number of times that letter appears. In C++, the char…arrow_forwardInclude the IPO chart and algorithm.arrow_forward
- Backward String Design a program that prompts the user to enter a string and then displays the string contents backward. For instance, if the user enters "gravity" the program should display "“ytivarg."arrow_forwardTask 3: High cholesteral and high triglycerides have been assicuated with cardiovascular disease. During yearly medical visits a doctor might recommend certain actions if certain test results are received (see Table 1). Write a program that allows the user to enter the numeric cholesteral and triglyceride results and the gives the doctor a recommendation. Please show step-by-step on LabVIEW. Table 1 Recomendation Triglyceride (mg/fL) Total cholesteralSuggest a full workup >886 >240 mg/dLSuggest change in diet 500 to 886 200 to 239Suggest change in activity 150 to 499 N/AAll good <150 <200 Task 4: Create a new version of your file for Task 4. Add two boolean indicators (Round LED). Oneshould light up when both Triglyceride AND Cholesteral levels are in the “All good” range. Theother should light up when either Triglyceride OR Cholesteral levels are in the “Suggest a fullworkup” range. Please show step-by-step on LabVIEW.arrow_forward5. Maximum Occurring Character Given a string, return the character that appears the maximum number of times in the string. The string will contain only ASCII characters, from the ranges ('a'-'z','A'-'Z','0'-'9'), and case matters. If there is a tie in the maximum number of times a character appears in the string, return the character that appears first in the string. Example text = abbbaacc Both 'a' and 'b'occur 3 times in text. Since 'a'occurs earlier, a is the answer. Function Description Complete the function maximum Occurring Character in the editor below. maximumOccurringCharacter has the following parameter: string text: the string to be operated upon Returns char: The most occurring character that appears first in the string. Constraints • 10 ≤ |text| ≤ 104 • All characters are alphanumeric, in the ranges ('a'-'z','A'-'Z','0'-'9') ======== 999992 14 15 16 17 18 19 20 21 2 2 2 2 22 23 24 25 2222 26 class Result { * * Complete the 'maximumOccurring Character' function below. * का…arrow_forward
- Remaining Time: 54 minutes, 49 seconds. * Question Completion Status: QUESTION 19 Write a Java program that prompts the user to enter the School Grade Level of a student and then calculate their discount amount in the regular fees structure offered during this pandemic situation. By using the below table, calculate their discount amount from the amount of the regular fee and then print the discount amount in OMR by using the appropriate selection structure. (Assume the user is entering a maximum Grade level is 12) discount amount = Regular Fees * percentage of discount rate School Grade Level Regular Fees in OMR Discount Rate >9 and 6 and 3 and 0 and <=3 30.500 5% otherwise 20.400 No discount T T T Arial 3 (12pt) v T -E E- 只i ン Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers TOSHIBA F5 F6 F7 F8 F9 F10 F11 F12 INS SCNULL LOCK AD & 67 7 V 8A9 4 0arrow_forwardProgramming Exercises Chapter 4, #1 Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.arrow_forwardParty-On sells individual hot/cold cups and dessert plates for parties. SueChen wants a program that allows her to enter the price of a cup, the price of a plate, the number of cups purchased, and the number of plates purchased. The program should then calculate the total cost of the purchase, including the sales tax. Finally, the program should display the total cost on the screen. Desk-check your solution’s algorithm using $0.50 as the cup price, $1 as the plate price, 35 as the number of cups, 35 as the number of plates, and 2% as the tax rate. Then desk-check it using $0.25, $0.75, 20, 10, and 6%.arrow_forward
- chapter 7 assignment design a payroll program that prompts the user to enter an employee's hourly pay rate and the hours worked validate the user's input so that only pay rates in the range of $7.50 through $18.25 and hours in the range of 0 through 40 are accepted the program should display the employees gross pay.arrow_forwardProblem 7: Pennies for Pay Write a program that caclulates how much a person would earn over a period of time if his or her salary is one penny the first day and two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing how much the salary was for eah day, and then show the total pay at the end of the pay period. The output should be displayed in a dollar amount, not the number of pennies. Input validation: Do no accept a number less than 1 for the number of days worked. A) Write the psuedocode, B.) a flowchart of , and C.) answer to the problemarrow_forwardAreas of Rectangles The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education