How to Implement Classes in a CSI 101 Homework Assignment?

  • Thread starter Calculus!
  • Start date
  • Tags
    Homework
In summary, the conversation is about creating a command button click event procedure for a homework assignment using classes. The code will read four integers from text boxes, calculate the average and maximum value, and place them into text boxes. The class will contain four integers as member data, a constructor or SET function, and two method functions. The code can be created in Visual Studio or .NET Framework, but it is not necessary. The homework assignment is not to recreate the form.
  • #1
Calculus!
20
0
Hey I need a lot of help with this homework assignment. I really have no idea of what to do. Please help me!

Write the command button Click event procedure from Homework #7 using classes. You should define the class, then write the code contained in the Click event that would use the class.

As a reminder, Homework #7 read four integers from text boxes, calculated the average and maximum value, and placed them into text boxes. Your code will do that again, but use a class. Your class will contain four integers as member data. The data must obtain the values in the text boxes, so you will need a constructor or SET function. You’ll also need two method functions, one that returns the average and one that returns the maximum value. Clearly, neither of those will require arguments.

You can create this code in Visual Studio or .NET Framework if you wish, but it isn’t necessary. I only need the code, you do not need to recreate the form.


Homework #7

'This is the code to be placed within the _Click() event of the button labeled START

'Declarations. These are needed, as you DO NOT receive any data from the arguments.
' The arguments to the Click event are set by Visual Studio options. Adding any to
' the function declaration simply means that you receive 0 values for the other arguments
Dim A As Integer, B As Integer, C As Integer, D As Integer 'The 4 integers
Dim Average As Decimal 'Must be decimal, as we want decimal places
Dim Max As Integer

'Obtain the 4 integers. Remember to convert them, as Text boxes hold Strings
A = CInt(txtNum1.Text) 'The Text property of a text box holds its value
B = CInt(txtNum2.Text)
C = CInt(txtNum3.Text)
D = CInt(txtNum4.Text)

Average = (A+B+C+D)/4
txtAverage.Text = Format(Average,”##0.00”) 'Format function isn't necessary.
'Could have used CStr function instead
'Didn't have to convert here, as Visual Studio does it for you, but it's best not
' to get comfortable with that. Not all compilers will automatically do that.

'Find maximum. Here I use a running max. I set the first number to max. I then compare
' each successive number. If the number is greater is max, I set max equal to the larger
' number. At the end, Max holds the highest value
Max = A
If B > Max Then Max = B
If C > Max Then Max = C
If D > Max Then Max = D

txtMax.Text = Cstr(Max)

Me.Refresh 'Necessary to immediate see changes to output boxes


Please Help Me! Thank you.
 
Technology news on Phys.org
  • #3


Hello! It seems like you are struggling with your CSI 101 homework assignment. I understand the importance of seeking help when needed, so I am happy to assist you with this task.

Firstly, let's break down the instructions for the assignment. You are asked to write a command button Click event procedure using classes. This means that you will need to define a class, write the code for the Click event, and use the class to obtain and calculate the average and maximum values from four integers entered in text boxes.

To start, you will need to create a class that contains four integers as member data. This class will also need a constructor or SET function to obtain the values from the text boxes. Additionally, you will need two method functions, one that returns the average and one that returns the maximum value.

Next, you can use this class in the Click event procedure. This event will read the four integers from the text boxes, use the class to calculate the average and maximum values, and place them in the corresponding text boxes. Remember to convert the values from the text boxes to integers and use the Format or CStr function to display the values with the appropriate decimal places.

Finally, you can test your code in Visual Studio or .NET Framework, but it is not necessary. The most important thing is to provide the code for the Click event, so you do not need to recreate the form.

I hope this explanation helps you with your assignment. If you have any further questions or need more clarification, do not hesitate to reach out for help. Good luck!
 

1. What is CSI 101?

CSI 101 is an introductory course in crime scene investigation, also known as forensic science. It covers the basic principles and techniques used in gathering and analyzing evidence at a crime scene.

2. Who can benefit from Homework Help for CSI 101?

Homework Help for CSI 101 can benefit students who are currently enrolled in the course, as well as those who are interested in learning more about forensic science. It can also be useful for professionals in the field who want to refresh their knowledge.

3. What topics are typically covered in CSI 101?

CSI 101 typically covers topics such as crime scene investigation techniques, evidence collection and preservation, forensic analysis of physical evidence, and the role of forensic science in the criminal justice system.

4. How can Homework Help for CSI 101 improve my understanding of the subject?

Homework Help for CSI 101 can provide additional explanations and examples that can clarify difficult concepts. It can also offer practice exercises and quizzes to help reinforce your understanding of the material.

5. Is Homework Help for CSI 101 the same as cheating?

No, Homework Help for CSI 101 is not the same as cheating. It is intended to supplement your learning and help you understand the material better. Copying answers without understanding them is considered cheating and will not benefit your learning in the long run.

Similar threads

  • Programming and Computer Science
Replies
2
Views
715
  • Programming and Computer Science
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
4
Views
910
  • Programming and Computer Science
Replies
1
Views
645
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
55
Views
11K
  • Programming and Computer Science
Replies
17
Views
3K
Back
Top