Pep/8 & c++ @ newton 2.0

 

 Problem 1: (8 points) Run the mystery program from Fig 6.16 with the values supplied in the help solution of Pep8 and some of your own

a) Show 3 screen shots with different inputs, including the output using Batch I/O

b) State in one sentence, what does this program do?

c) Modify the program to make the output clearer – Describe – Do not paste the code

 

Show the same 3 screen shots with the modification

d) Is this spaghetti code or structured code? If it was the other type, would it be easier or harder to modify?

 

Note: Review presentation on Using Pep8 Trace Tags before beginning the following problems.

Also, work each of these programs in steps. Get one part working before trying to add all the requirements. If you feel you cannot complete it, submit what you have and the last working version. Start early and email me with problems, I will give you hints and direction.

Problem 2: (14 points) Translate the program below into PEP/8 assembly language

Start with Assembly code for Fig 6.36 (Use Pep8 help)

Change to output array in same order as input

Add function twoVect

Pass array as parameter as shown in Fig 6.38

Use trace tags on all variables.

a) Comment lines of the source code to trace the C++ code. Cut & paste the Source Code Listing into your assignment document.

b) Run for a set of 4 inputs and paste a screen shot of the Output area of PEP/8.

c) Step thru & Cut and paste the memory trace when in the twoVect function.

 

#include <iostream> using namespace std;

void twoVect(int v[], int n){

int k;

for(k = 0; k < n; k++){ v[k] = v[k] * 2;

}

} int main () {

int vector[4];

int j;

for (j=0; j<4; j++){

cin >> vector[j];

}

twoVect(vector, 4); for (j=0; j<4; j++){

cout << j << ‘ ‘ << vector[j] << endl;

}

return 0;

}

Problem 3: (14 points) Translate the program below into PEP/8 assembly language

Use a jump table to implement the switch statement.

Use trace tags on all variables.

For invalid scores, output should be the same as the C++ program.

Add something to the output that makes this program uniquely yours.

The variable finish needs to be local.

This is similar to Fig 6.40.

a) Comment lines of the source code to trace the C++ code. Cut & paste the Source Code Listing into your assignment document.

b) Run for each score and paste a screen shot of each of the PEP/8 Output area.

c) Step thru & Cut and paste the memory trace at any point.

 

#include <iostream>

using namespace std;

int main () { int finish;

cout << “Enter your score: 1, 2, 3, 4, or 5” << endl; cin >> finish;

switch (finish) { case 1:

cout << “you’re first!” << endl;

break; case 2:

cout << “you’re second!” << endl;

break; case 3: case 4:

cout << “you’re not first or second” << endl;

break;

default:

cout << “you weren’t even competing” << endl;

}

cout << endl; return 0;

}

Problem 4: (14 points) Write a C++ program that inputs a lower case character, converts it to an upper case character using the function below and increments it to the next character (i.e. B will be changed to C). If Z is entered it should be changed to A. If a non-letter character is entered, it should not be changed.

A character that is not a letter should be returned as is.

Character variables will need character trace tags.

Hint: characters only use one byte of storage and should be manipulated with byte instructions.

Add something to the output that makes this program uniquely yours.

Then translate it to Assembly language.

a) Cut and paste you C++ Source Code into your assignment document.

b) Comment lines of the source code to trace the C++ code. Cut & paste the Assembly Source Code Listing into your assignment document.

c) Run for 3 inputs: one uppercase, one lowercase, & one non-letter and paste a screen shot of each in the Output area of the PEP/8.

d) Step thru & Cut and paste the memory trace at a point when in uppercase subroutine.

 

char uppercase (char ch) { if ((ch >= ‘a’) && (ch <= ‘z’)) { return ch – ‘a’ + ‘A’;

} else { return ch;

}

 

}

Calculate Your Essay Price
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more