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
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!
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
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.