The writer is very fast, professional and responded to the review request fast also. Thank you.
COP 3014: Fall 2018 Homework 4
Total Points: 200 Due: Friday, 11/16/2018
The objective for this assignment is to make sure
2 Program 1 – Writing Functions – 75 points
Squilliam Fancyson has heard of the fancy calculator that Squidward (supposedly) made for the Krusty Krab’s Cash Register. Determined to prove that he is the best programmer in town, he has challenged Squidward to a series of programming challenges. If Squilliam wins, Squidward has to hand over his clarinet and never paint again. If Squidward wins, Squilliam will work Squidward’s shift at the Krusty Krab’s cash register for a week. Squidward is determined to win, except he is not really a programmer. He has left no stone (pioneer transport or otherwise) unturned. He has even tried asking Karen, who was unable to help. He realizes that instead of working off Mr. Krabs’ old computer (the one Patrick smashed while painting the house), he could just pay you to do the challenges for him. Your task today is to help Squidward retain his sanity and dignity (whatever is left of it).
The first challenge is to write a few mathematical functions. For this program, we define a new term called Special Difference. The Special Difference of a number is the difference between the number and the one you obtain by reversing its digits. For example, the Special Difference of 1234 is 3087 (| 1234 – 4321 |).
1
We also find the value of ex using the Taylor’s series expansion. The Taylor’s Series expansion of ex is defined as
e =
Please make sure your program conforms to the following requirements.
number. (20 points)
2.1 Sample Run
Calculating the Special Differences:
Enter the numbers:
1234
57
982
603
-2
The Sum is 4095
Calculating e^x through Taylor’s Series Expansion:
Enter the value of x: 5
Enter the number of terms: 20
e^x is 148.413
3 Program 2 – Array Operations – 75 Points
Squilliam has been soundly beaten in the first challenge. He still refuses to give in. It is now a best of 3 challenge. The next item on the agenda is array operations. For this program, we’re going to perform a range of standard array operations to show Squilliam once and for all, that Squidward is familiar with arrays and how they work. You’re required to write functions to insert and delete
inf
x ????xn x0 x1 x2 x3
n!=0!+1!+2!+3!…
1. Write a function called reverse that takes a number as a parameter and returns the reversed
n=0
2
elements from an array, and sort the array. We’re also going to write a command line menu to do these tasks repeatedly. For this problem, you can assume that the array size will never drop below 1 and will never rise above 99.
Please make sure you conform to the following requirements:
Algorithm for insertion sort
loop i from 1 to Length(A)
x = A[i]
j=i-1
loop as long as j >= 0 and A[j] > x
A[j+1] = A[j]
j=j-1 end loop
A[j+1] = x
end loop
3.1 Sample Runs
Enter the number of elements you want to enter (Max 100): 5
Enter 5 numbers
2.5 6 -7 10.7 0.8
1. Insert an element
2. Remove an element
3. Print the array
3
4. Sort the array
5. Exit
Enter your option: 1
Enter the number: 3.1
Enter the position: 2
Element Inserted.
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 3
The array is:
2.5 6 3.1 -7 10.7 0.8
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 4
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 3
The array is:
-7 0.8 2.5 3.1 6 10.7
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 2
Enter the element: 0.8
Element deleted.
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 3
The array is:
-7 2.5 3.1 6 10.7
4
1. Insert an element
2. Remove an element
3. Print the array
4. Sort the array
5. Exit
Enter your option: 5
Goodbye!
4 Program 3 – Matrix Norms – 50 points
The competition is heating up. The special judging panel, consisting of Karen, Old Man Jenkins and Sandy, do not want to release the results of the previous challenge until this one is complete as well. For this challenge, you have to compute the Max Norm of a matirx. The Max norm of a ma- trix is defined as the largest elements of a matrix. Write a C++ program to compute the Max norm.
Please make sure you conform to the following requirements:
4.1 Sample Run
Enter the number of rows: 3 Enter the number of columns: 3 Enter the matrix:
-3 5 7
2 16 4
028
The max Norm is: 16
5 Extra Credit Problem – Simple Calculator – 50 points
In the distant and slightly dystopian future, the Grand Poobah has banned the use of hand held calculators. Some say he was hit on the head with one. Others believe it is due to his fear of accountants. Either way, hand calculators are a thing of the past. However, you find yourself in sudden need of a calculator that can perform simple calculations. No worries. You are a C++ programmer and you can write a console application to do this.
This program does not serve any practical purpose and is, in fact, a very inefficient way to de- sign a calculator. This exercise is just to give you some practice in writing functions.
5
Specifications
5.1 Sample Run
Enter the expression:
1
+
26
*
2
%
19
/
5
=
The result is 3
5.2 Sample Run 2
Enter the expression:
12
*
9
-
37
+
-8
=
The result is 63
6 Generic Guidelines
1. Include the header comment with your name and other information on the top of your files.
6
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more