Question

In: Computer Science

All of these programs need IO. So you must use appropriate Visual Studio solution as the...

All of these programs need IO. So you must use appropriate Visual Studio solution as
the template (windows32 has been provided in the book’s website and you supposed
to know how to use it as it was required in the previous assignment)

Write an assembly language program to calculate the following.
(((((20 + 21) × 22) + 23)×24)+25 : : :) + 2n
Hint: Note that when n is even, carrying result is multiplied by 2n. When n is odd,
carrying result is added to 2n (above formula shows the case where n is odd).
As an example, when n = 5, it should print 352.
You need to have a dialog box to read the value of n.
You need to check for n < 0 and display an appropriate error message.
As n increases, at one point, you will not be able to hold the result in a 32-
bit register. You should check for it (probably using jo instruction), display an
appropriate error message.
Valid result should be displayed using a message box.

Solutions

Expert Solution

'NOTE: I DON'T GET THE FORMULA PROPERLY, I THINK, IT'S NEED TO RECHECKED.

'NOTE: I'VE MADE THE LOGIC. YOU ENTER THE STARTING POINT AS PER REQUIREMENT

'NOTE: if n = 5. it shows 35 (according to you, the result is 352. i think it was a typing mistake.)

' if n = 5 the formula will be. (((((0+1)x2)+3)x4)+5) + 2x5 = 35

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Please Enter a Number") 'checks the test box is empty or not
Else
Dim n As Long
n = Long.Parse(TextBox1.Text) 'store the value of text box into n
n = Val(n)
If n < 0 Then 'checks the n is positive or not
MsgBox("Error: Please Enter a Valid Number")
Else
Dim result As Long
Dim nxt As Long
result = 0
For i As Long = 0 To n - 1 'ENTER YOUR STARTING POINT AS YOUR REQUIREMENT
nxt = i + 1
If (i Mod 2 = 0) Then 'checks whether the i is odd or even
result = result + nxt
Else
result = result * nxt
End If
Next
If (n Mod 2 = 0) Then
result = result * (2 * n) 'multipling when n is even
Else
result = result + 2 * n 'adding when n is odd
End If

MessageBox.Show(result, "Result")
End If
End If
End Sub
End Class


Related Solutions

MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following three arrays: int array1 [] = { 3, 4, 2, 1, 7}; float array2 [] = {0.3, 0.1, 5.5, 4.3, 7.8}; char array3 [] = {‘c’, ‘d’, ‘a’, ‘b’, ‘f’};                                     Develop a driver function to print out the sorted results and put the screenshot into the word document. Note that you have to use qsort( ) provided by Visual Studio. What is the...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course. Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable...
Using Visual Studio Code (JavaScript) For this lab you must use a reasonable faceted search example,...
Using Visual Studio Code (JavaScript) For this lab you must use a reasonable faceted search example, each item must have at least three categorical attributes and at least one numeric attribute. Attributes such as ID, name etc do not count as categorical or numeric attributes. Exercise 1 (a) Define a class for your item that meets the above three categorical and one numeric attribute requirements. (b) Create a text file that contains at least 5 such records in CSV format....
I need the code for following in C++ working for Visual studio please. Thanks Use a...
I need the code for following in C++ working for Visual studio please. Thanks Use a Struct to create a structure for a Player. The Player will have the following data that it needs maintain: Struct Player int health int level string playerName double gameComplete bool isGodMode Create the 2 functions that will do the following: 1) initialize(string aPlayerName) which takes in a playername string and creates a Player struct health= 100 level= 1 playerName = aPlayerName gameComplete = 0...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for name, one for hours worked,and the last for hourly rate. The arrays will receive the information from inputs from the screen.For example, you will ask the following three questions: a) Employee name: b) Hours worked: c) Hourly rate: After you have received all ten records and have inserted them into the array, you will then calculate the hourly rate times the hours worked to...
You should use Visual Studio to write and test the program from this problem.   Write a...
You should use Visual Studio to write and test the program from this problem.   Write a complete program with a for loop that (5 pts) uses proper variable types. (10 pts) uses a for loop to read in a real numbers exactly 8 times (10 pts) adds the number read in the loop to a running sum. (10 pts) Computes the average of the 8 numbers as a real number. (5 pts) Prints the correct result with 2 decimal places,...
The solution has to be written on C++ Visual Studio Thank you (Package Inheritance Hierarchy) Package-delivery...
The solution has to be written on C++ Visual Studio Thank you (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. Use class Package as the base class of the hierarchy, then include classes TwoDayPackage and OvernightPackage that derive from Package. Base class Package should include data members representing the name, address, city, state and ZIP...
Create a C++ project in visual studio. You can use the C++ project that I uploaded...
Create a C++ project in visual studio. You can use the C++ project that I uploaded to complete this project. 1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which...
Your solution must include all supporting calculations and these supporting calculations must be performed with appropriate...
Your solution must include all supporting calculations and these supporting calculations must be performed with appropriate Excel formulas. Failure to do so will result in a reduction in points. For each case, you must submit one printed copy of the Excel spreadsheet which contains your case solution and a second printed copy displaying the formulas contained in each cell of the spreadsheet. Be sure to format your spreadsheet so that your work is clearly presented and easy to review. Wright...
Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as...
Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as the project type. It will create a file and a class definition in that file.  Rename the file to be ToDo.cs  and accept the suggestion which will also rename that class to be Class Todo { } In that class, create             - a string property called Title             - an int property called  Priority             - a bool property called Complete Also, define one Constructor that takes in one...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT