Chat with us, powered by LiveChat Pep/8 & C++ @ Newton 2.0 | Writedemy

Pep/8 & C++ @ Newton 2.0

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;

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order