From the textbook: Big C++: Late Objects, Enhanced: Business P2.6 The following

From the textbook: Big C++: Late Objects, Enhanced:
Business P2.6
The following pseudocode describes how to turn a string containing a ten-digit phone number (such as “4155551212”) into a more readable string with parentheses and dashes, like this: “(415) 555-1212”.
Take the substring consisting of the first three characters and surround it with “(” and “)”. This is the area code.
Concatenate the area code, the substring consisting of the next three characters, a hyphen, and the substring consisting of the last four characters. This is the formatted number.
Translate this pseudocode into a C++ program that reads a telephone number into a string variable, computes the formatted number, and prints it.
Horstmann, C. S. (2017). Big C++: Late Objects, Enhanced eText (3rd ed.). Wiley Global Education US.
Design Specification: Verify that the program design aligns with the description of the desired interface, including prompts for input and output. Remember that the design should clearly communicate the purpose of the program, the desired behavior the user should engage in, and the results with effective labeling of the output.
Functional Specification: Verify that the program functions based on the desired capability and process as described in the program description.
Instructions
After analyzing the problem and specifications described in the background above, in a Word document, create the pseudocode (language agnostic and using conventions in the text) that describes the algorithm and logic for the proposed solution to the problem scenario.
Verify that the algorithm and logic are well structured (unambiguous, executable, and terminating) based on conventions described in the reading. Create a C++ project in Visual Studio and translate the algorithm and logic described in pseudocode to a working program that has been tested and compiled.
Ensure that a comment header (based on the template provided under Learning Resources) is included at the top of your .cpp file and that descriptive in-line comments that follow conventions described in the reading are used throughout your code.
Create a single zip file containing your Visual Studio project folder and pseudocode document. Name the zip file using the following convention – LastNameFirstNameAssignmentNumber. Example: SmithJohnAssignment1
Length: 1 ZIP file containing the Visual Studio Project folder and all related files and the Word document containing pseudocode.

Posted in C++

For this homework assignment I am giving you three files: The Homework02.h Downl

For this homework assignment I am giving you three files:
The Homework02.h Download Homework02.h header file which contains the prototypes of the various functions needed
The Homework02.cpp Download Homework02.cpp C++ file which will contain the implementations of the functions defined in Homework02.h.
I am giving you the implementation of two of these functions
computeFTk
initializeOriginal
The file correct-1000.dat Download correct-1000.dat, which contains the Fourier transform of the function defined in initializeOriginal when 1000 data points are used. You can use this file to check whether your program is functioning correctly.
A MS Word document (Homework02Timing.docx) which you will fill out with timing data from your finished program. See below for more details.
Your job will be to implement the other functions defined in Homework02.h and develop a program that can run in a multithreaded way. The DFT is an ideal example of a one-to-one data parallel program that can be multithreaded without synchronization. Please take time to study the source code I’m providing to help understand the variables and functions used in this program!
Homework requirements
Your program must operate in the following manner: Note that there are several layers of helper functions which you must implement.
The program should take two int command-line arguments. The first one is the number of samples in the function (N) and the second is the number of threads to use for the computation (nthreads). If two arguments are not provided, the program should print an error message to standard output and exit with status 0. See the sample output below for details.
Note that you normally would write the error message to standard error and exit with a non-zero status. However, due to limitations in the CODE plugin, you must use standard output and status 0.
The program should define and initialize vectors to hold the original function and its Fourier transform. Because the Fourier transform is complex, you will need two vectors to define the functions — one for the real part and one for the imaginary part. Create and initialize vectors oR, oI, fR, and fI.
The program should then define the original function via a call to the initializeOriginal function. For this assignment, the original function is a sinc functionLinks to an external site. with a = 4.
I am giving you the implementation of initializeOriginal.
After initializing the original function, the program should compute the Fourier transform via a call to the computeFT function, which you will implement based on the prototype in Homework02.h. computeFT should divide the problem across threads in the same manner as discussed in class for one-to-one data parallelism.
The function that each thread runs is computeFTMT, which you will implement based on the prototype. For each value of k that the thread is working on, computeFTMT will call the computeFTk function to calculate the kth component of the Fourier transform.
I am giving you the implementation of computeFTk.
When the computation is complete, you should write out the resulting Fourier transform (k, fR[k] and fI[k]). The code to use for this is available in comments in the Homework02.cpp file.
To check if your program is working correctly, run it for N = 1000 and compare the output with that in the correct-1000.dat file I have provided.
You can do this most efficiently using the diffLinks to an external site. command.
Your program’s output should be exactly the same as what’s in that file — close is not good enough.
You should get the same results regardless of the number of threads you use.
After testing that your program gives the correct output for N = 1000, you will run it for a larger value of N and time the program with /usr/bin/time for different numbers of threads.
For this assignment, your virtual machine will need to be defined with at least 4 processors. Note that this is only necessary after you have written, debugged, and tested the program for N = 1000. To change the number of cores, power off your VM, then edit the virtual machine settings to increase the number of processors to at least 4. You can change this back to its current value after you have completed this assignment.
When your program is working correctly, and you have at least 4 CPUs assigned to your virtual machine, run and time the program for N = 40000 and 1, 2, 3 and 4 threads via
$ /usr/bin/time ./Homework02 40000 1 > /dev/null
$ /usr/bin/time ./Homework02 40000 2 > /dev/null
and so on for 3 and 4 threads. Then use the output of /usr/bin/time to complete the table in the Homework02Timing.docx file. Note: If you are not seeing the elapsed time drop as you increase the number of threads then there is a problem with your multithreading implementation!
Output Samples
No command line arguments
$ ./Homework02
Usage: Homework02 N nthreads
Only one command line arguments
$ ./Homework02
Usage: Homework02 N nthreads
Two command line arguments – 1 thread
$ ./Homework02 10 1
0 3.516133994 0
1 3.513802601 0.1356541907
2 3.503210897 0.3119196779
3 3.447089869 0.6622405087
4 5.195194731 1.038296187
5 5.16526981 1.774031285e-16
6 5.195194731 -1.038296187
7 3.447089869 -0.6622405087
8 3.503210897 -0.3119196779
9 3.513802601 -0.1356541907
Two command line arguments – 4 threads — should be identical to the output with one thread!
$ ./Homework02 10 4
0 3.516133994 0
1 3.513802601 0.1356541907
2 3.503210897 0.3119196779
3 3.447089869 0.6622405087
4 5.195194731 1.038296187
5 5.16526981 1.774031285e-16
6 5.195194731 -1.038296187
7 3.447089869 -0.6622405087
8 3.503210897 -0.3119196779
9 3.513802601 -0.1356541907
This assignment is tailored to the incremental development approach I discussed in class as it’s possible to implement it without multithreading and still get some credit.
A lot of the coding concepts you need can be gleaned from the lecture slides.
DO NOT use global variables!
Make sure that you are compiling with these options: -g -Wall -std=c++17 -O3

Posted in C++

Description Instructions Create a C++ dictionary app with a loop that prompts th

Description
Instructions
Create a C++ dictionary app with a loop that prompts the user for words to look up.
Study the https://github.com/fromlc/ex9_dictionary.git
Use the global string arrays dict::words and dict: defs for words and definitions. You may add words and their definitions if you wish.
Good code recognizes commands typed in any case, but for this exercise search for the word exactly as the user types it.
Don’t worry about validating user input – assume valid input for this exercise.
Get your lookup working first, and only then should you code the user prompt loop.
Write a function named lookup_word) that looks up words in the dict:words array.
Your function should accept two arguments:
a string reference parameter for the word to look up, and
a string reference parameter to hold the returned definition.
Your function should return an int that holds either:
the index of the word’s definition in the dict::words and dict::defs arrays, OR
o -1 if the word is not found in dict.:words array
In your function lookup_word(), call the string compare() function in a loop to search for the a word
Start by searching for a hard-coded word (“cat” or “dog”).
Once you can display a word’s correct definition, add the user prompt loop and look up the user’s words.
Terminate your loop when the user types
“quit” in all lowercase.
Submitting your work
Check the assignment rubric,
Test your code,
Fix all compiler errors and warnings, and
Submit your completed cp file.

Posted in C++

Description Instructions Create a C++ dictionary app with a loop that prompts th

Description
Instructions
Create a C++ dictionary app with a loop that prompts the user for words to look up.
Study the https://github.com/fromlc/ex9_dictionary.git
Use the global string arrays dict::words and dict: defs for words and definitions. You may add words and their definitions if you wish.
Good code recognizes commands typed in any case, but for this exercise search for the word exactly as the user types it.
Don’t worry about validating user input – assume valid input for this exercise.
Get your lookup working first, and only then should you code the user prompt loop.
Write a function named lookup_word) that looks up words in the dict:words array.
Your function should accept two arguments:
a string reference parameter for the word to look up, and
a string reference parameter to hold the returned definition.
Your function should return an int that holds either:
the index of the word’s definition in the dict::words and dict::defs arrays, OR
o -1 if the word is not found in dict.:words array
In your function lookup_word(), call the string compare() function in a loop to search for the a word
Start by searching for a hard-coded word (“cat” or “dog”).
Once you can display a word’s correct definition, add the user prompt loop and look up the user’s words.
Terminate your loop when the user types
“quit” in all lowercase.
Submitting your work
Check the assignment rubric,
Test your code,
Fix all compiler errors and warnings, and
Submit your completed cp file.

Posted in C++

Description Instructions Create a C++ dictionary app with a loop that prompts th

Description
Instructions
Create a C++ dictionary app with a loop that prompts the user for words to look up.
Study the https://github.com/fromlc/ex9_dictionary.git
Use the global string arrays dict::words and dict: defs for words and definitions. You may add words and their definitions if you wish.
Good code recognizes commands typed in any case, but for this exercise search for the word exactly as the user types it.
Don’t worry about validating user input – assume valid input for this exercise.
Get your lookup working first, and only then should you code the user prompt loop.
Write a function named lookup_word) that looks up words in the dict:words array.
Your function should accept two arguments:
a string reference parameter for the word to look up, and
a string reference parameter to hold the returned definition.
Your function should return an int that holds either:
the index of the word’s definition in the dict::words and dict::defs arrays, OR
o -1 if the word is not found in dict.:words array
In your function lookup_word(), call the string compare() function in a loop to search for the a word
Start by searching for a hard-coded word (“cat” or “dog”).
Once you can display a word’s correct definition, add the user prompt loop and look up the user’s words.
Terminate your loop when the user types
“quit” in all lowercase.
Submitting your work
Check the assignment rubric,
Test your code,
Fix all compiler errors and warnings, and
Submit your completed cp file.

Posted in C++

A Sorted List ADT is to be extended by the addition of function SplitLists, whic

A Sorted List ADT is to be extended by the addition of function SplitLists, which has the following specifications: SplitLists(SortedType list, ItemType item, SortedType& list1, SortedType& list2) Function: Divides list into two lists according to the key of item. Preconditions: list has been initialized and is not empty. Postconditions: list1 contains all the items of the list whose keys are less than or equal to item’s key; list2 contains all the items of list whose keys are greater than item’s key. A) Implement SplitLists as a member function of the array-based Sorted List ADT. B) Implement SplitLists as a member function of the linked Sorted List ADT. C) Compare the algorithms used in (A) and (B). D) Implement SplitLists as a client function of the array-based Sorted List ADT. E) Implement SplitLists as a client function of the linked Sorted List ADT.

Posted in C++