JustAnswer



Student Lab Activity Lab # CIS CIS170A-A1Lab 2 of 7: Input and Output with VariablesLab Overview – Scenario / Summary:TCOs:TCO 2 - Given a set of program specifications for a simple business problem requiring the use of input and output, code and test a program that meets the specifications and employs best programming practices.TCO 3 - Given a set of program specifications for a simple business problem requiring the use of arithmetic expressions and built-in methods, code and test a program that meets the specifications and employs best programming practices.This lab will accomplish the following:Input and output the user’s nameInput the length of a side of a square and calculate and output the areaInput the radius of a sphere and calculate and output the volumeDeliverables:StepDeliverablePointsA-5Project Files 20B-5Project Files 25The dropbox deliverables include the following: For each exercise, include a zipped file with all the files from your Visual Basic project (see directions in Doc Sharing on how to collect and zip files.)Upload each part of the lab into its corresponding weekly dropbox.Part A: Basic Input / OutputStep 1: Open a new projectBe sure to have gone over Part A several times before you begin your laboratory assignment. In this part of the lab, you are asked to create a Visual Basic Windows Form application, without providing the specific instructions.Create a new Windows Forms project in VB. Name your project CIS170A_Lab02_AStep 2: Program DescriptionIn this project, you will create a Windows Form application that will collect the user’s first name, last name, major, and date of graduation. When the user selects “Display Information” a message box will be displayed that shows the input information and how many days remain before the user graduates from school. [Hint: Check section “Dates as Input and Output” (p. 87-88 in our textbook.)]Step 3: Suggested form designYou are free to experiment with form design and object colors as you see fit, even though as to colors we strongly recommend using the default colors for the form and all objects – this allows each user to see your form in their chosen Windows color palette.A possible form design is as follows:Here we show some sample data entered in the textboxes and a given date selected in the DateTimePicker.Note that in the suggested design above we use a DateTimePicker object, which is a very handy way to obtain a date from the user. You have at least two ways to use the date selected by the user:Use dtpGradDate.Value within your code (that is, the Value property of the DateTimePicker object); or Apply the Date.TryParse() method to the Text property of the DateTimePicker object: Date.TryParse(Me.dtpGradDate.Text, dtmGradDate)To compute the number of days between dates, consider using the DateDiff() function. Doubts about this function? Please post question in the Lab Q&A forum in class. Some additional information about the DateDiff() function is as follows:DateDiff() functionThe DateDiff() function returns a Long value which will have the indicated number of intervals (days, months, etc.) between the two dates specified as arguments to the function.The function has three main arguments (there are others but let’s only focus on the first three):Interval. This first argument indicates the type of intervals that we want the function to count. The options are: DateInterval.Day, DateInterval.Month, DateInterval.Minute, DateInterval.Second, and many others.)Date 1. This second argument is the first date (must be a DateTime data type.)Date 2. This third argument is the second date (must also be a DateTime data type.)The function is used in a statement such as the following one:lngDaysToGrad = DateDiff(DateInterval.Day, Today(), dtmGradDate)Here, the arguments are as follows:DateInterval.Day – We want the count of intervals to be done in days.Today() – This function returns the date of today (i.e., the current date from the computer’s clock.)dtmGradDate – This variable has the second date we want to count the intervals to.So, the function will compute the number of days between today and the dtmGradDate date, and the result will be assigned to variable lngDaysToGrad.Once you validate all input data and compute your results, consider using a MessageBox.Show() method to display your final message, as follows:Note that the display above is split into three lines and there are many ways to do this. One of those ways requires inserting vbNewLine in the spot of the display string where you want the line to split. Doubts about this? Please post questions in the Q&A discussion forum in class.Step 4: Implement the Event HandlersConsider using the following suggested TOE chart as guide in designing your program’s event handlers:TaskObjectEventCompute NumberOfDays between Today and GraduationDateSet output string to FirstName & “ “ & LastName & “: Major = “ & Major & vbNewLine & “Graduation date = “ & GraduationDate & vbNewLine & “Only “ & NumberOfDays & “ days away!!!”Display output stringbtnDisplayClickClear all textboxes & date (today)btnClearClickClose form [Hint: use “Me.close”]btnExitClickPlease note that beginning this Week 2 you are required to set Option Strict On for all your Labs. To do this, please include the following statement as the first executable statement in your program:Option Strict OnIn addition to this, and also beginning this Week 2 you are required to add profuse internal documentation to your program. Program internal documentation typically consists of:Program Header: Identification of the program Identification of the programmer Date written List of modifications (including author and date) Procedure Headers (for each module, event procedure, function, procedure, or segment of code): Identification of the module Overall logic (pseudocode) Interface with the calling program (i.e., parameter list), if used Calling procedure (event that causes its execution or statements necessary for invoking it), if used Inline comments: You should include comments within the code itself, for those elements that are a little obscure, or which you think require some explanation. It is a good idea to write the internal documentation as you progress through the program’s development. Do not leave it all to the last minute or when the application is complete. If you do so, the documentation will most likely be written poorly or not at all. Please note that internal documentation is highly valued in your Labs -- don't leave home without it.Problem-Solving Questions (“IDEAL” problem-solving methodology):Identify the problematic situation.What are the user requirements?Why would the user want to have the input data together with the graduation date and computed days until that date displayed on screen?What are the validation rules for each of the input values?How the user wants to enter or select the value of the graduation date?What does the user wants done when the “Compute” button is pressed?What does the user wants done when the “Clear” button is pressed?What does the user wants done when the “Exit” button is pressed?Define the problem and goals.How can the problem be described in words?What form objects need to have some action defined?What would the working form look like when each of the buttons is pressed?What action should be taken when each button is pressed?What tests can we execute on the finished program to ascertain correct functioning?Explore and evaluate possible solution strategies.How do we obtain the data entered by the user?What happens if the user does not enter any data for First / Last Name, Major, or Graduation Date?What form object should be used to accept the Graduation Date from the user? A textbox? A date-time picker? Some other form object?What variables do we need to declare in the program?How are the days between “today” and the Graduation Date computed?How do we obtain today’s date from the computer?How is the output message assembled, given that it consists of letters, a date, and numbers?What specific statement or method should be used to display the final results? A second form? An MsgBox() function? A MessageBox.Show() method? Some other technique?How do we clear each of the form objects used?How should the program be internally documented?Anticipate the outcomes. Choose, justify, and implement a solution.How should the solution to the problem be coded in Visual Studio?Look back at learning and evaluate the solution.Does the solution compile correctly?Can the input data be entered in the form? Can the user select the Graduation Date as expected?Does the solution correctly compute the days between “today” and the given Graduation Date?Is the output message correctly and neatly displayed?Does the solution properly clear (reset) the date form object when the “Clear” button is pressed?Can you summarize in a few sentences what you learned in this Lab?NOTE: These questions are meant to help you identify the problem presented in the Lab and resolve it. You should not submit written replies to the questions as part of your Lab.Step 5: DeliverablesZip up the top-level folder with your program (the complete set of project files) into a single file (please check Doc Sharing for details.)Rename that .zip file as CIS170A_Lab02_A_LastName_FirstInitial.zip, or similar.Place deliverables in the Dropbox.END OF PART APart B: Arithmetic OperationsStep 1: Create a New ProjectOpen a new project in . Name your project CIS170A_Lab02_B Step 2: Program DescriptionIn this project, you will create a program that will provide the user the option of calculating the area of a square, the area of a circle, or the volume of a sphere. The program will accept a single input from the user (length of side or length of radius) and depending on the button clicked by the user, the program will compute either the area of a square with the length as a side; the area of a circle with that value as the radius; or the volume of a sphere with that value also as a radius. The corresponding mathematical formulas are as follows:Area Of Square = Length x Length (or also Length squared)Area of Circle = Pi x Radius squared (i.e., raised to the power of 2)Volume of Sphere = 4 / 3 x Pi x Radius cubed (i.e., raised to the power of 3)(where Pi = 3.1416)Step 3: Suggested Form DesignYou are free to experiment with form design and object colors as you see fit, even though as to colors we strongly recommend using the default colors for the form and all objects – this allows each user to see your form in their chosen Windows color palette.A possible form design is as follows:Here we show some sample data entered in the textbox, and the result of the user having then clicked on the “Square” button.Note that in this case we display the results in a big label located in the center of the form. Please consider the following values for two of that label’s properties:AutoSize = FalseBorderStyle = Fixed3DStep 4: Implement the Event HandlersConsider using the following suggested TOE chart as guide in designing your program’s event handlers:TaskObjectEventMake sure that the textbox has a valid numeric value. [Hint: use the Double.TryParse() method.]Assign the converted input value to dblInputCompute AreaOfSquareDisplay “The area of a square with side xxx is yyy”, where “xxx” is dblInput and “yyy” is AreaOfSquare.btnSquareClickMake sure that the textbox has a valid numeric value. [Hint: use the Double.TryParse() method.]Assign the converted input value to dblInputCompute AreaOfCircleDisplay “The area of a circle with radius xxx is yyy”, where “xxx” is dblInput and “yyy” is AreaOfCircle.btnCircleClickMake sure that the textbox has a valid numeric value. [Hint: use the Double.TryParse() method.]Assign the converted input value to dblInputCompute VolumeOfSphereDisplay “The volume of a sphere with radius xxx is yyy”, where “xxx” is dblInput and “yyy” is VolumeOfSphere.btnSphereClickClear textbox and output label.btnClearClickClose formbtnExitClickPlease be sure to convert the numeric values to the appropriate data type when displaying the results.Problem-Solving Questions (“IDEAL” problem-solving methodology):Identify the problematic situation.What are the user requirements?What are the validation rules for the input values?How the user wants to enter or select the length of the side / radius of the geometrical shape desired?What does the user wants done when the “Square”, “Circle”, and “Sphere” button is pressed?How should the results be displayed?What does the user wants done when the “Clear” button is pressed?What does the user wants done when the “Exit” button is pressed?Define the problem and goals.How can the problem be described in words?What form objects need to have some action defined?What would the working form look like when each of the buttons is pressed?What action should be taken when each button is pressed?What tests can we execute on the finished program to ascertain correct functioning?Explore and evaluate possible solution strategies.How do we obtain the data entered by the user?What happens if the user does not enter any data for Length / Radius?What variables do we need to declare in the program?How should the input be validated? Can the input be numeric? Date? String?How is the area of a square computed?How is the area of a circle computed?How is the volume of a sphere computed?How is the output message assembled, given that it consists of letters and numbers?How should the program be internally documented?Anticipate the outcomes. Choose, justify, and implement a solution.How should the solution to the problem be coded in Visual Studio?Look back at learning and evaluate the solution.Does the solution compile correctly?Can the input data be entered in the form?Does the program correctly check that a valid number has been entered? Is the user informed of the input error?Does the solution correctly compute the area of a square / circle and the volume of a sphere?Is the output message correctly and neatly displayed?Can you summarize in a few sentences what you learned in this Lab?NOTE: These questions are meant to help you identify the problem presented in the Lab and resolve it. You should not submit written replies to the questions as part of your Lab.Step 5: DeliverablesZip up the top-level folder with your program (the complete set of project files) into a single file (please check Doc Sharing for details.)Rename that .zip file as CIS170A_Lab02_B_LastName_FirstInitial.zip, or similar.Place deliverables in the Dropbox.END OF PART BEND OF LAB 2 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download