Lab 5 Solution

$35.00 $29.05

You'll get a: . zip file solution, download link after Payment

Category: Tag:

Description

Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is highly encouraged that you ask questions and take notes. In order to get credit for the lab, you need to be checked off by the end of lab. For non-zero labs, you can earn a maximum of 3 points for lab work completed outside of lab time, but you must finish the lab before the next lab. For extenuating circumstance, contact your lab TAs and Instructor.

THE TAS WILL SPLIT YOU IN HALF AT THE START OF THE LAB. IF YOU ARE NOT WORKING ON THE PROFICIENCY DEMO, YOU SHOULD BE WORKING ON THE REFACTORING CODE PORTION OF THIS LAB.

(7 pts) 1-hour Practice Proficiency Demo

  1. First, open a terminal on the host computer:

    • Once setup, right click “Open Terminal”

    • Make sure you type vim to use vim, not just vi, and create test.cpp

    • To run your program, use ./test.cpp

  1. Get 2 questions from the TA. Choose one question you want to solve. All questions include variables, user input, conditional execution, and repetition. You should be able to finish the code within one hour.

o Scoring:

o You get max 7 points for fully coding the solution

o You get max 5 points for getting pretty far, but not finishing the if/else or loop logic

o You get max 3 points for main, libraries, variables, and reading input. o You get max 1 point for no clue but showing up!!!

  1. When you finish, get a TA to check you off.

You MUST get checked off for the above before leaving lab.

(3pts) Refactoring Code

In your terminal grab the following code

wget http://classes.engr.oregonstate.edu/eecs/winter2018/cs161-001/labs/lab5_refactor.cpp

This code was written with out the use of functions making it very hard to read. Your goal is to reduce main down to as few lines as possible. Use your knowledge of functions gained from week four and add the appropriate functions to the program. The output should not change. The program is meant to solve problems such as the

following:

Future Value Trade Offs

You have a choice between receiving $1000 today or $1100 one year from now. If interest rates are 6%, which should you choose?

  1. Find future value at year one of $1000 FV = PV(1+(i/m)^(n*m)

PV = 1000, i = 0.06, n=1, m=1

  1. Find present value of $1100

PV = FV/(1+(i/m)^(n*m))

  1. Compare the present value of the future offer against the future value of the present offer. Choose which ever is worth more.