代写Assessment 1 Exercise代写留学生R语言

Assessment 1

Exercise A-20 Marks

Write a C program that calculates the definite integral of a polynomial of up to order 3 (a cubic function) over a specified range.

The polynomial is given by:

f(x) =a + bx + cx2+ dx3

Write a program that will prompt the user to enter the order of a polynomial, up to a maximum of 3 (cubic, four coefficients a, b, c, and d). A quadratic is order 2, a straight line of order l, a constant of order 0. Arrays may not be used. Ask the user to enter the lower and upper limits of integration (x_1 and x_2). Calculate the definite integral of f(x) between these limits, using the analytical formula for theintegralfapolynomial:

Display the result of the integration in the form.

The definite integral of f(x) from x - <number> to x = <number> is:l <result>

Your code must capture invalid inputs (x_1>=x_2 is invalid, the polynomial order must be between between 0 and 3). The program should repeat until the user selects that they have no more funetions to input. It should also confirm with the user that the coefficients they have entered are correct before completing the integral. It should not ask for coefficients outside of the order of the polynomial. Comment effusively. Your code may not use arrays, functions, classes, strings to solve the problem. You must use the material from lectures 1-4 only.

Hint: d= 0 in a quadratic (order 2) polynomial, c=d=0 in a straight line (order 1) and b=c=d=0 in ad constant function (order 0).

Sample output:

Enter order of equation (0 to 3): 3

Enter coefficient of x^3: 2

Enter coefficient of x^2: 0

Enter coefficient of x^1: -4

Enter constant term: 3

Confirming that your equation is:

f(x) = 2.00x^3 + 0.00x^2 + -4.00x + 3.00 ?

(1 for yes, 0 for no): 1

Enter lower limit of integration: 0

Enter upper limit of integration: 2

The definite integral of f(x) from x = 0.00 to x = 2.00 is: 6.0000

Do you want to enter another function? (1 for yes, O for no): 0 

Program finished. Goodbye!

Exercise B-20 Marks

Write a C program that simulates the growth of a savings account alongside the repayment of a loan. The program will generate month by month comparisons of net money. The user will input:

the initial savings balance,

the monthly "excess money" amount (between £50 and £150 that can be used for either savings or loan repayment),

the initial loan amount,

the interest rate for the loan,

and the number of years for the simulation to run (i.e. the time length of the loan) (up to 4 years).

The savings account offers an annual interest rate of 5.5% on the balance up to £5,000, and 1.06% on any portion of the balance above £5,000. All interest is compounded monthly. You will need to convert the annual effective interest rates into a monthly rate for the calculations. The formula for finding the monthy interest rate (i) from an annual rate is:

                           Equation 1

Hint: remember that 5.5% is expressed as 0.055 in this equation.

To find the amount of interest earned you will take the savings balance and multiply it by i. This can then be added to the balance, along with the monthly "excess cash" deposit for finding the savings balance. Note you will have to amend this equation to handle amounts above and below £5000.

savings balancenew = savings balancecurrent (1 + i) + excess money

In parallel, you will calculate repaying a loan with a user-specified initial value. The loan's annual effective interest rate can be chosen to be one percentage point lower, equal to, or one percentage point higher than the savings account's top rate (i.e. 4.5%, 5.5% or 6.5%). You will assume that the user will pay the standard monthly repayment (P) of the loan in addition to the "excess money" that is being entered. For a loan of initial amount (V) paid over years (Y), and with an effective monthly rate found using Equation 1 (i), you can calculate this by using:

A loan balance is calculated by finding the interest earned on the loan and adding that to the balance of the loan, then subtracting the repayment put into the loan as well as subtracting any of the "excess money" that is paid into the loan.

loan balancenew = loan balancecurrent (1 + i) - P — excess money

Once the loan is paid off, P should also go into savings. The program will show the scenario of putting:

1. all the excess money into the loan until the loan is paid off then all into savings,

2. all the excess money into savings,

3. all the excess money into savings until the savings reaches £5000 then all into the loan.

You must display, for each month of the year period, the balance of the savings and balance of the loan for each of the 3 scenarios in a table, side by side. Remember the loan balance must stop at £0: it cannot become less than £0. An example output is available on the next page. You may not use user defined functions, arrays or strings. You should use define to store the annual interest rates of the savings account and then calculate all monthly effective rates in the code.



热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图