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;

}

 

}

Order a unique copy of this paper
(550 words)

Approximate price: $22

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

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

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

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

Read more

Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

Read more

Privacy policy

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

Read more

Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Read more

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