CS160-Assignment 6 -Integration without Calculus: Code your algorithm Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

 Find Your Sense of Belonging:

Studies show that students who find their sense of belonging in an engineering discipline are more likely to stay in that discipline. Therefore, I want you to think about where you might find this sense of belonging in the college of engineering OR in computer science.  This can be within a club, research, experiential learning experience, a job, a center, or a living-learning community.

Write a paragraph (3-5 sentences) about your specific plans to build YOUR sense of belonging in the next year at OSU. You must pick 2 items that you plan to do to create this sense of belonging, and you must be specific about how you think this will help you.

(70 pts) Code Your Algorithm/Experiment with your computation

We have been learning about problem-solving steps, control structures, and functions. In this computational section, you will use your understanding of selection and repetition control structures, as well as decomposition/functions, to solve the following problem.

Design a program to calculate the summation or integration of three different functions:

f1(x) = 10x

f2(x) = 2x2 – 5

f3(x) = x+20

Your program will ask the user to decide if they want to calculate the summation or integration and for which function (f1-f3). If integration is chosen, then you need to ask the user which approximation method to use, i.e. rectangle or trapezoids.  This will help you gain experience thinking about when to use selection, repetition, and functions to solve a problem.

Your program will be very robust and handle all errors, and it will be properly decomposed into tasks and subtasks.  Your design needs to clearly indicate what these tasks/functions will be and the corresponding algorithm you will use in each task.  For example, you will likely need a task to get the user’s choice of summation or integration, and you will need tasks for calculating the summation and integration.

Summation Explanation:

Your program should determine the summation of whichever function the user chooses (f1-f3), but think about the evaluation of the function as a task itself to abstract the details of which function you are evaluating. For Example, if your f(x) = 2x:

𝑏 ∑2x

𝑥=𝑎

a is the starting point/lower limit for x and b is the stopping point/upper limit for x.  If the user enters a starting point of 0 and stopping point of 2, then the summation would be 2*0+2*1+2*2 = 6 (or more abstractly f(0)+f(1)+f(2)).

Integration Explanation:          

Your program should determine the area under the function the user chooses to integrate, and you will calculate the area under a curve using the rectangle or trapezoid method, depending on the method the user chooses.  Don’t freak out!!! Programming integration into the computer does not consist of calculus!!!!!!  It is simple math, and these two methods only require summing the area of a certain number of rectangles or trapezoids under a specific curve, f(x).

For Example, if your f(x) = 2x:

Basic Numerical Methods (Rectangle vs. Trapezoid):

n = number of rectangles and/or trapezoids a = beginning x value b = boundary for rectangles

width = width of each rectangle/trapezoid, (b-a)/n

height_rectangle = f(x), where x changes by width for each rectangle

height_trapezoid = (f(x1)+f(x2))/2, where x1 and x2 change by width for each trapezoid area = width * height

 

The functions are bounded by any interval on the x-axis, including both positive and negative values!!!.  You can check your answers:

http://www.wolframalpha.com/widgets/view.jsp?id=8ab70731b1553f17c11a3bbc87e0b605

 ) Program Testing

Take your test plan from your design and add any additional case, as well as test all cases to see if your actual results match your expected results.

o What are the actual results from your good, bad, and edge cases for ALL input in the program?

 

(10 pts) Extra Credit I:

Implement the ability to have the user repeat this process until they no longer wish to do calculations without recursion or calling another function to accomplish this task.  Hint: You should use a while loop to implement this!

OR

(10 pts) Extra Credit II:

Document what you are struggling with the most in this assignment or class.

  • Is it coming up with the algorithm, the code, understanding the labs, etc?
  • What do you feel could make a better learning environment for you (please don’t say me not being gone so much this quarter because that isn’t something I can help, and I really hope you understand)?

o Provide suggestions for future assignments and classes to make this a better class.

  • Assignment6-hekfla.zip