Sale!

CPSC 240 Assignment 2 Arrays solution

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (5 votes)

Goals

Make an assembly program that teaches all of the following:

=how to make an array

=how to implement iteration

=how to make professional looking programs

=how to reject invalid inputs

=how to put on your resume: “I program in assembly for sheer enjoyment.”

Programming requirements

 

Make a hybrid program that produces the following output.  Additional details will be given later.

 

This style of programming is sometimes called hybrid programming because it uses functions taken directly from the libraries of C and C++.  Sometime there is no known function in the C++ library of functions that meets our needs then we create a brand new C++ function and use it when needed.

Sample run #1

Welcome to Arrays of Integers

Bought to you by Jaime Ward

 This program will sum your array of integers

Enter a sequence of long integers separated by white space.

After the last input press enter followed by Control+D:

3

-12

9

21

-4

13  <enter>  <cntl+D>

These number were received and placed into the array:

3   -12    9     21    -4   13

 

The sum of the 6 numbers in this array is 54.

The sum will now be returned to the main function.

Main received 54, and is not sure what to do with it.

Main will return 0 to the operating system.   Bye.

Color codes:

Blue background is produced by module Input_Array

 

Yellow background is produced by module Manager

 

Green background is produced by module Display_Array

 

White background is produced by module Main

 

Module sum does not produce any output.

Sample run #2

Welcome to Arrays of Integers

Bought to you by Jaime Ward

 This program will sum your array of integers

Enter a sequence of long integers separated by white space.

After the last input press enter followed by Control+D:

3

-12

9

2R7

The last input was invalid and not entered into the array.

-4

5   <enter><cntl+D>

 

These numbers were received and placed into the array:

3   -12    9    -4   7

 

The sum of the 6 numbers in this array is 3.

 

The sum will now be returned to the main function.

 

Main received 3, and is not sure what to do with it.

Main will return 0 to the operating system.   Bye.

Sample run #3

 

Welcome to Arrays of Integers

Bought to you by Jaime Ward

 

This program will sum your array of integers

Enter a sequence of long integers separated by white space.

After the last input press enter followed by Control+D:

3    -9     2R64

That number is invalid and not accepted

12    -4     13 <enter> <cntl+D>

 

These numbers were received and placed into the array:

3   -9    12     -4    13

 

The sum of the 5 numbers in this array is 15.

 

The sum will now be returned to the main function.

 

Main received 15, and is not sure what to do with it.

Main will return 0 to the operating system.   Bye.

Other facts

 

The language used in each module is shown in the individual rectangles.

 

Obviously you change the name of the author in the example to be your own name.

 

Make a bash file that compiles and runs everything related to this program.

 

In brief your program has to be in the Professional class or it will not be graded.  There have been many lectures about properties of Professional Programs and now you have to make one.  [Assignment 1 was exempt from this requirement.]

There are 5 functions in the program.  You can see their names in the diagram above.

 

Main calls Manager; Manager calls Input_Array, Display_Array and Sum.

 

There will be five files – each file contains one source function.

 

The sixth file is the Bash file that will compile the 5 sources (in any order) and then link the 6 object files making one executable file.

 

 

When you are done

 

This assignment can count for extra credit.  It is not a requirement to do this programming exercise.

 

 

When your program works correctly.   Then make it cosmetically correct.  Use a software license.  Explain what important parts of the code do.  Remove any old comments remaining from the professor’s old program.  Remove the professor’s name and put your own name in the proper places.

 

Send the program to me in an email message with 6 attachments.  In the subject line place the string “CPSC 240 Assignment 2 for Credit”.

 

Don’t email me broken code.  It is better to discuss fixing code during the lab portion of the class meeting.

 

 

 

Due: Tomorrow.

CPSC 240 Assignment 2