CST8219 – C++ Programming
The goal of this lab is to creating a Java GUI, and calling a C++ function using the GUI.
Week 8 Powerpoint materials on Brightspace. There are many reference websites at the end of the powerpoint slides.
1. Create a new directory called Week8 for this lab. Create a Java GUI that has a text field saying: “Enter the number of samples to generate:”. You should then also have an edit text that lets users type in an integer, followed by a button that says “Go!”
2. When the user clicks on the Go button, read the number that the user has typed, and create an array of int in Java, and initialize it with random numbers. Use [login to view URL] as your random number generator. It has a nextInt() function that you should call repeatedly in a for loop. Once the array is generated, you will pass the array to two C++ functions to calculate the mean, and standard deviation of the array. The function signatures in Java should be:
public native double calculateSTDDev( int  numbers );
public native double calculateMean(int  numbers );
3. You should then have two text fields that show the results of what the functions returned:
4. If you use Java 1.8, use the javac command to compile your Java class file, and then use the javah command to generate the .h header file. If you use Java 1.9 or newer, use javac -h to generate the header file. You must then create the .cpp file that implements the function declarations that are created.
5. Then create a [login to view URL] file that will compile a library instead of an executable. Normally, you would write a line: add_executable(MyProjectName file1.h [login to view URL] file2.h [login to view URL] …etc). This time, change that line to add_library(Week8 headerFile.h [login to view URL]) , but change the filename from headerFile to whatever file the javah program generates.
Submission: Create a zip file containing everything in your week8 directory and submit it on Brightspace. Make sure it includes your Java gui class, the .cpp and .h, and your [login to view URL] file
Marks: (total of 10)
The Java Gui has a text input field for the number of samples, and a button to start the computation +1
Your Java class has 2 public native functions declared +2
Your C++ header file has 2 functions generated by javah +1
Your C++ implementation (.cpp) file computes the mean and stddev +2
The results are correctly displayed on the gui +2
Your [login to view URL] file builds a library instead of an excutable file +1
Your Java class loads the correct library generated by your CMakeLists +1
I have 4 years of experience with C++, 3 years of experience with C++ algorithms from HackerRank and codeforces and 1 year of experience with Java. Your task seems fairly straightforward, I'll start working right away
10 freelancers are bidding on average $186 for this job
Hello. How are you today? I have read your project description clearly. I have developed projects of C++ Programming and have 8 years experience. I want to work with you for a long time. Thank you very much.