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;

}

 

}

US Custom Writers
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.