The Expert's number of “Accepted Answers” is a good indication of how many satisfied customers he or she has helped.
Ingo U's MASTER OF SCIENCE in ELECTRICAL AND COMPUTER ENGINEERING was verified on or about July 2010 by a leading third-party verification service.View the Terms of Service section on verifications
You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in a- "First Number" [textbox]b- "Second number" [texbox]c- "Result" [textbox] - read onlyd- "+" [push button] "-" [push button] "/" [push button] "*" [push button]f- "Save" [push button] "Display" [push button]2- OperationsThe user will enter two numbers in the "First Number" and the "Second Number", then pressthe "+" for addition, "-" for subtraction, "*" multiplication and "/" the result will be displayed in the result [textbox], if the user clicked "[save]" then the operation can be displayed in the right panel when the user press [Display]Please note that the user can save up to 10 operations. Add "clear" [push button] on the right panel to clear the content, make sure that you trap all the errors and set the focus to the appropriate control after the error occurred- Make sure that the result contains the operations, I should see in the right panel something like this 1+1=2 1*2=2 and so on.
Object Oriented ProgrammingYou are going to enhance the application by creating two main classes 1- Create a class for the math ( "+","-") operations -- name the class "MathOp" 2- Extend the class using inheritance to include ("*","/") name the class "MathOp2"3- Create the following class/function when select a line from the list box, the user should be able to modify the values/operations and save it to the listbox/database Let’s say the user clicked on “1+3=4” , the values 1,3 should be displayed in the input text boxes.
This is the first part that I have so far.
Public Class Form1
Dim Num1 As Decimal Dim Num2 As Decimal Dim Num3 As Decimal Dim blnSave As Boolean 'indicator if save button was pressed
Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAdd.Click Num1 = TextBoxNum1.Text Num2 = TextBoxNum2.Text Num3 = Num1 + Num2 TextBoxNum3.Text = Num3 End Sub
Private Sub ButtonSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSubtract.Click Num1 = TextBoxNum1.Text Num2 = TextBoxNum2.Text Num3 = Num1 - Num2 TextBoxNum3.Text = Num3 End Sub
Private Sub ButtonMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMultiply.Click Num1 = TextBoxNum1.Text Num2 = TextBoxNum2.Text Num3 = Num1 * Num2 TextBoxNum3.Text = Num3 End Sub
Private Sub ButtonDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDivide.Click Num1 = TextBoxNum1.Text Num2 = TextBoxNum2.Text Try Num3 = Num1 / Num2 Catch ex As DivideByZeroException When Num2 = 0 MessageBox.Show("Cannot divide by 0, Please try again") TextBoxNum2.Focus() End Try TextBoxNum3.Text = Num3
Private Sub ButtonClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click ' ListBox1.Clear() ListBox1.Items.Clear() My.Computer.FileSystem.WriteAllText("test.txt", "", False) End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Dim file As System.IO.StreamWriter file = My.Computer.FileSystem.OpenTextFileWriter("test.txt", True) file.Write(TextBoxNum1.Text) file.Write(TextBoxNum2.Text) file.Write("=") file.Write(TextBoxNum3.Text) file.WriteLine() file.Close() End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click Dim lines() As String = IO.File.ReadAllLines("test.txt") ListBox1.Items.AddRange(lines) End SubEnd Class
For this assignment, you will modify studentRecords.py, which has been distributed with this assignment. The framework for the functions that I want you to write has been provided, along with a few helper functions to get you started. The studentRecords.py program allows users to enter, modify, and delete records corresponding to student data. Each student record contains a name, a 4-digit student ID, and a major. A sample file with records (students.txt) was distributed with this assignment. You will use that file in your program. You will write the following 5 functions. You should note that the header for these functions has already been put into studentRecords.py. DO NOT MODIFY THE HEADERS. The behavior of these 5 functions is as follows: