Assignment Chef icon Assignment Chef

Browse assignments

Assignment catalog

33,401 assignments available

[SOLVED] Cop3504c lab 07: the cow strikes back

Overview This lab’s purpose is to provide students with experience in inheritance of classes and working with multiple classes. It is recommended that students use command line tools and editors for this lab (though it is not strictly speaking required). This lab will require students to build on their previous lab experience, in which a version of the cowsay utility was created; however, this lab will be written in C++. Note that you will need to set the language version to C++17 in your CMakeLists.txt file for this project. Specification Students will convert the driver program (cowsay) from Java and also create two new classes – Dragon and IceDragon. The Dragon class should extend the Cow class, and IceDragon must be derived from Dragon. As before, the HeiferGenerator class is provided for you – but updated to a C++ version (HeiferGenerator.cpp and HeiferGenerator.h). It will also handle the new Dragon class and its subtypes. You must also prepare a CMake build file for this project. Students may implement private attributes and methods if they chose to do so. This is not required – it is purely optional. No public attributes / methods should be added to the specification! Executable Specification Your program must accept command line arguments as follows: cowsay ‐l Lists the available cows cowsay MESSAGE Prints out the MESSAGE using the default cow cowsay ‐n COW MESSAGE Prints out the MESSAGE using the specified COW In addition, this version of the utility handles a special set of Cow-derived Dragon classes (and its subclasses). Whenever a dragon-type cow is selected, the display of the message must be followed by a line stating whether or not the dragon is fire-breathing: finn@BMO:~$ ./cowsay ‐n dragon Fiery RAWR Fiery RAWR |___/| / //|\ /0 0 __ / // | / / /_ / // | _^_’/ /_ // | //_^_/ /_ // | ( //) | // | ( / /) _|_ / ) // | _ ( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐. (( / / )) ,‐{ _ `.|.‐~‐. .~ `. (( // / )) ‘/ / ~‐. _.‐~ .‐~^‐. (( /// )) `. { } / (( / )) .‐‐‐‐~‐. ‐’ .~ `. __ ///.‐‐‐‐..> _ ‐~ `. ^‐` ///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’ This dragon can breathe fire. finn@BMO:~$ cowsay ‐n ice‐dragon Ice‐cold RAWR Ice‐cold RAWR |___/| / //|\ /0 0 __ / // | / / /_ / // | _^_’/ /_ // | //_^_/ /_ // | ( //) | // | ( / /) _|_ / ) // | _ ( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ (( / / )) ,‐{ _ `.|.‐~‐. (( // / )) ‘/ / ~‐. _.‐~ (( /// )) `. { } (( / )) .‐‐‐‐~‐. ‐’ ///.‐‐‐‐..> _ ///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ This dragon cannot breathe fire. Cow Class The Cow class must have all the same methods as previously required, though students may add private methods. The methods are repeated here, briefly, for reference. (Note that setImage() should be marked as virtual.) public Cow(const string& _name) // Constructor public string& getName() // Returns name of this cow object public string& getImage() // Return image for this cow object public virtual void setImage(const string& _image) // Sets image for this cow object Dragon Class The Dragon class must be derived from the Cow class and must make all its methods available. You may mark any additional methods virtual as necessary. In addition, Dragon must provide the following methods: public Dragon(const string& _name, const string& _image) Constructor; creates new Dragon object with given name and image. This must be its only public constructor! public bool canBreatheFire() This method should exist in every Dragon class. For the default Dragon type, it should always return true. IceDragon Class The IceDragon class must be derived from the Dragon class and must make all its methods available: public IceDragon(const string& _name, const string& _image) Constructor; creates a new IceDragon object with the given name and image. This should be the only public constructor for the IceDragon class! public bool canBreatheFire() For the IceDragon type, this method should always return false. HeiferGenerator Class (Provided) public static vector& getCows() Returns a reference to a vector of cow object pointers from built-in data set. This will call the Cow constructor and setImage() methods of the cow class if needed to initialize new cow objects uniquely for each data set. public static Dragon* getDragonPointer(Cow* candidate) If object pointed to by candidate is a Dragon (including an IceDragon), returns a Dragon pointer to the object. Otherwise, returns nullptr. Submissions NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission! (Note that matching sample output is necessary, but not sufficient, for full credit.) Files: cowsay.cpp, Cow.cpp, Cow.h, Dragon.cpp, Dragon.h, IceDragon.cpp, IceDragon.h, CMakeLists.txt Method: Submit on Canvas Sample Output finn@BMO:~$ ./cowsay finn@BMO:~$ ./cowsay Hello World! Hello World! ^__^ (oo)_______ (__) )/ ||‐‐‐‐w | || || finn@BMO:~$ ./cowsay ‐n kitteh Meow‐Meow! Meow‐Meow! (“`‐’ ‘‐/”) .___..‐‐’ ‘ “`‐._ ` *_ * ) `‐. ( ) .`‐.__. `) (_Y_.) ‘ ._ ) `._` ; “ ‐. .‐’ _.. `‐‐’_..‐_/ /‐‐’ _ .’ ,4 ( i l ),‐” ( l i),’ ( ( ! .‐’ finn@BMO:~$ ./cowsay ‐n ninja Hello world! Could not find ninja cow! finn@BMO:~$ ./cowsay ‐l Cows available: heifer kitteh dragon ice‐dragon finn@BMO:~$ ./cowsay ‐n dragon Firey RAWR Fiery RAWR |___/| / //|\ /0 0 __ / // | / / /_ / // | _^_’/ /_ // | //_^_/ /_ // | ( //) | // | ( / /) _|_ / ) // | _ ( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐. (( / / )) ,‐{ _ `.|.‐~‐. .~ `. (( // / )) ‘/ / ~‐. _.‐~ .‐~^‐. (( /// )) `. { } / (( / )) .‐‐‐‐~‐. ‐’ .~ `. __ ///.‐‐‐‐..> _ ‐~ `. ^‐` ///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’ This dragon can breathe fire. finn@BMO:~$ ./cowsay ‐n ice‐dragon Ice‐cold RAWR Ice‐cold RAWR |___/| / //|\ /0 0 __ / // | / / /_ / // | _^_’/ /_ // | //_^_/ /_ // | ( //) | // | ( / /) _|_ / ) // | _ ( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐. (( / / )) ,‐{ _ `.|.‐~‐. .~ `. (( // / )) ‘/ / ~‐. _.‐~ .‐~^‐. (( /// )) `. { } / (( / )) .‐‐‐‐~‐. ‐’ .~ `. __ ///.‐‐‐‐..> _ ‐~ `. ^‐` ///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’ This dragon cannot breathe fire.

$25.00 View

[SOLVED] Cop3504c lab 08: return of the cow

Overview This lab’s purpose is to provide students with experience in file I/O and C++ exceptions. It is recommended that students use command line tools and editors for this lab (though it is not strictly speaking required). This lab will require students to build on their previous lab experience, in which a version of the cowsay utility was created. Students will need to look up the constructors for some C++ standard objects, such as exceptions, in the C++ documentation to complete this lab. Note that you will need to set the language version to C++17 in your CMakeLists.txt file for this project. Specification Students will update the driver program class (cowsay) and also add one new class – FileCow. The FileCow class should extend the Cow class, and IceDragon must be derived from Dragon. As before, the HeiferGenerator class is provided for you – but updated to handle the new FileCow class. (Please refer to specification for previous lab for a refresher.) Students may implement protected attributes and methods if they chose to do so. This is not required – it is purely optional. No public attributes / methods should be added to the specification! Cowsay Class (Program Driver) Your program must accept command line arguments as follows: cowsay -l Lists the available cows cowsay MESSAGE Prints out the MESSAGE using the default cow cowsay -n COW MESSAGE Prints out the MESSAGE using the specified built-in COW cowsay -f COW MESSAGE Prints out the MESSAGE using the specified file COW Note that this version of the utility handles a special set of Cow-derived FileCow objects. The HeiferGenerator will automatically create FileCow objects (using the FileCow constructor) from files in the “cows” directory. Previous Work The following classes, developed previously, are required for this lab to function. Cow public Cow(const string& _name) // Constructor public string& getName() // Returns name of this cow object public string& getImage() // Return image for this cow object public virtual void setImage(const string& _image) // Sets image for this cow object Dragon (extends Cow) public Dragon(const string& _name, const string& _image) // Constructor public bool canBreatheFire() // Defaults to true >cowsay -l Regular cows available: heifer kitteh dragon ice-dragon File cows available: moose turkey turtle tux IceDragon (extends Dragon) public Dragon(const string& _name, const string& _image) // Constructor public bool canBreatheFire() // Returns false FileCow Class The FileCow class must be derived from the Cow class. In addition, FileCow must add the following behavior: public FileCow(const string& _name, const string& filename) Constructor; creates a new FileCow object with the given name and an image loaded from filename. If the file cannot be loaded, it should throw a new std::ifstream::failure exception object with the message “MOOOOO!!!!!!”. This should be the only public constructor for the FileCow class! public void setImage() Should throw a new std::runtime_error exception object with message “Cannot reset FileCow Image”. Submissions NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission! Files: rotc.zip Method: Submit on Canvas Compressed Archive (rotc.zip) We do not list required source files, only headers. You may include any additional source or header files in addition to those listed, but you must have the listed files at a minimum. Your compressed file should have the following directory/file structure: rotc.zip rotc (directory) CMakeLists.txt Cow.h Dragon.h FileCow.h IceDragon.h (Other sources / folders) Sample Output >javac Cowsay.java >java Cowsay Hello World! Hello World! ^__^ (oo)_______ (__) )/ ||—-w | || || >java Cowsay -n kitteh Moew-Moew! Moew-Moew! (“`-‘ ‘-/”) .___..–‘ ‘ “`-._ ` *_ * ) `-. ( ) .`-.__. `) (_Y_.) ‘ ._ ) `._` ; “ -. .-‘ _.. `–‘_..-_/ /–‘ _ .’ ,4 ( i l ),-” ( l i),’ ( ( ! .-‘ >java Cowsay -l Regular cows available: heifer kitteh dragon ice-dragon File cows available: moose turkey turtle tux >java Cowsay -n ninja Hello world! Could not find ninja cow! >java Cowsay -f tux Do you have any herring? Do you have any herring? .–. |o_o | |:_/ | // (| | ) /’_ _/` ___)=(___/ >java Cowsay -f alien Earth is ours! Could not find alien cow! >java Cowsay -f kitteh MEOW!!! Could not find kitteh cow! >java Cowsay -n tux How about tuna? Could not find tux cow!

$25.00 View

[SOLVED] Cop3504c lab 06: image scaling

Overview This lab is designed to give students practice with memory manipulation and function as a primer for Project 3. You will be using CLion, along with Windows Terminal and the test images provided on Canvas, to complete this lab. It will make use of a C++ version of the ConsoleGfx class. You will also practice directly executing programs from the command line. (Please note that the CLion terminal does note natively recognize UTF-8 encoding, and the C++ runtime does not do “unnecessary” re-encoding, so proper visualization requires using Windows Terminal and a modified character set. As a result, while this activity can be done on Linux or MacOS, the visualizations will not match the desired result on these platforms.) Requirements The program should be driven classless main function and Image class. Standalone Functions (scaler.cpp) int main() When the program is run via the main() method, the program should: 1) Fetch ConsoleGfx singleton via ConsoleGfx.getInstance() 2) Display the welcome message 3) Display color test (ConsoleGfx.testRainbow) 4) Display the menu 5) Prompt for input Load File Load file via unsigned char *ConsoleGfx.loadFile(string file). Note that loadFile() allocates an array for the file data, but the caller is responsible to deallocation. Success (File was Loaded) Failure (File wasn’t Loaded) Select a Menu Option: 1 Select a Menu Option: 1 Enter name of file to load: logos/uga.gfx Enter name of file to load: foo.png File loaded. Error: could not load file. Scaler Menu Scaler Menu ———– ———– Load Test Image Show Image Properties Loads ConsoleGfx.testImage: Displays the length and width of the current image. Select a Menu Option: 2 Select a Menu Option: 6 Test image data loaded. Image Dimensions: (14, 6) Scaler Menu Scaler Menu ———– ———– Display Image Displays current image by invoking ConsoleGfx.displayImage(unsigned char *imageData) method. Success (Previously Loaded) Failure (No Image Loaded) Enlarge / Shrink Image Prompts the user for orders of magnitude to change (powers of two), then enlarges the image. Select a Menu Option: 4 Select a Menu Option: 5 Enter orders of magnitude for enlargement: 3 Enter orders of magnitude for reduction: 3 Image enlarged! Image reduced! Scaler Menu _ Scaler Menu ———– ———– unsigned char *scaledImage(unsigned char *imageData, int orders) Returns a scaled version of the image data based on the orders of magnitude (i.e., powers of two to scale). The number of orders of magnitude should be in the range [-4, 4] (inclusive), which allows scaling down to 1/16 or up by a factor of 16 in each dimension. Do no implement this via recursive or iterative doubling; this takes twice as long as creating a new image one time, and it causes memory fragmentation. This function should never scale any image above 256 in width or height; instead, it should limit scaling such that the image is scaled up by a power of two but remains less than or equal to 256 in each dimension. Likewise, no image should be scaled below a height or width of one. To determine the color for reduced images, the number of colors of each pixel should be counted, and the most common color should be used. If there is a tie, the earliest pixel (by row, then by column) should be used. This function should allocate memory and return it to the caller; the caller is responsible for deallocation. Image Class The Image class will the image data and should be constructed from the raw data. The class must also have the following methods and behaviors (this is mandatory): public Image(unsigned char *imageData) This method should be the only constructor for this class. There should not be a default constructor! Its sole argument is a pointer to an array of raw image data as loaded from the file. The data is formatted as follows: public unsigned char *getImageData() Returns a pointer to the raw image data (not a copy). public unsigned char *getPixelData() Returns a pointer to the raw pixel data (excluding the image property information). Should not be a copy. public unsigned char getWidth() Returns the width of the image. public unsigned char getHeight() Returns the height of the image. public void setImageData(unsigned char *newData) Changes the image data to the new pointer. Building and Testing For this project, students will begin to learn more details about the practical building and testing of C++ programs, including accessing executables built by the compiler from outside of the IDE. Building CLion uses the standardized CMake build system, which is supported across multiple platforms and IDEs (including CLion and Visual Studio) and supports many compilers (GCC, Clang, and MS Visual C.) When you create a CLion project, it will create CMakeLists.txt. The CMakeLists.txt file for this lab might look like this: You should make sure that the CMakelists.txt file correctly lists your source files and the executable. Then, click on the “Build” button (���), which is on the toolbar to the left of the “Run” ( ) and “Debug” (�������) buttons. Testing Due to limitations of CLion’s (and “Command Prompt”) terminal, we will build our program using CLion but test using Windows Terminal. You should install it via the Windows Store. You will also need to add MinGW’s binary directory (C:ProgramDatachocolateylibmingwtoolsinstallmingw64bin) to the system’s PATH variable (see Microsoft’s instructions). To open Explorer , open the build folder (e.g, cmake-build-debug), right-click on scaler.exe, and select Open In  Explorer. Then, right click in Explorer and select “Open in Windows Terminal”. Once the terminal window is open, you can run your program by typing the executable’s name (e.g., scaler): cmake_minimum_required(VERSION 3.20) project(scaler) set(CMAKE_CXX_STANDARD 14) Executable name add_executable(scaler ConsoleGfx.cpp scaler.cpp) Source files C++ version Submissions NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission! Files: scaler.cpp, Image.cpp, Image.h Method: Submit on ZyLabs

$25.00 View

[SOLVED] Cop3504c lab 05: software engineering

Overview The objective of this lab is to understand the purpose and usefulness of debugging and version control. Debugging is an essential skill needed to be a successful developer. We will use PyCharm’s built-in debugger. We will also practice functions of version control systems to develop familiarity in them. Specification You will be debugging your previous solution code in this lab. After you have demonstrated to a lab instructor that you can successfully debug a program, you push a program up to your GitHub repository. Debugging 1) Open your IDE (PyCharm by default) 2) Open your previous solution (or another lab/project if you didn’t complete the previous lab) 3) Demonstrate breakpoints, the watch window, and the stack trace window to your lab instructor (online students may create a short screencast instead) Git Practice / Setup 1) Complete these exercises: https://try.github.io/levels/1/challenges/1 2) Create a GitHub educational account: https://education.github.com/pack/join 3) Install Git for your OS if necessary. (You can download Git here: https://git-scm.com/downloads) Optionally, you may also want to install a GUI client for Git and a windowed merge tool. You can get SourceTree (https://www.sourcetreeapp.com/) and Meld (https://meldmerge.org/) for free. (Directions for using Meld with SourceTree: https://jaehoo.wordpress.com/2018/05/21/source-tree-resolve-conflicts-with-an-external-tool/) Git Tasks 1) Create an empty repository on GitHub and add a README.md (markdown) file. Each student should clone. 2) Individually convert your Java solution from the previous lab (analyzer.py) into C++ (analyzer.cpp). 3) Add and commit your converted solution to the GitHub repository. Each student should attempt to push. 4) The second push should create a merge conflict. You should work together to resolve this, then push. 5) Both students should pull the changes, and then the student who does not own the repository should fork it. 6) After forking, each student should set the repository to private and add their lab instructor to the repo. When you convert to C++, you can use the std::chrono::system_clock::now() function to measure times. If you are unfamiliar with the command line and would like to learn it, this guide will help (for Mac, Linux, and Git-Bash on Windows): http://www.ee.surrey.ac.uk/Teaching/Unix/ Submissions For campus students, the debugging section of this lab requires a “check-off” in lab. For UF Online students, this may be submitted instead as a screencast on Canvas. Your GitHub repository can be demonstrated in person (for check-off) or can be checked later.

$25.00 View

[SOLVED] Cop3504c lab 03: the cow says…

Overview This lab is designed to introduce students to the Bash Command Line Interface (CLI) and the concept of CLI arguments and give them practice writing classes. For (only) this lab, you are not allowed to use any windowed editor (such as IntelliJ, Eclipse, or Notepad++). Instead, you will use a Unix-based command line editor. The cowsay utility is a popular Unix program from the 20th century (see https://en.wikipedia.org/wiki/Cowsay). You will write a slightly simplified cowsay program that takes in several arguments and prints out different text depending on the arguments. You must log in to the school computers using your CISE account to do this lab. Tools Please note that you must use a text editor and the terminal to edit and run your program and its directories. It is advised students learn/review basic Unix shell commands before beginning; a good run-through can be found here: https://linuxjourney.com/lesson/the-shell. Follow these steps to get started on the lab: 1) Open a terminal and enter the pwd command to identify the path to the working (current) directory (folder) 2) Enter ls to list the contents of the current directory 3) Use the mkdir command to make a new directory called CowLab. 4) Use ls to see the change, then cd to change to the directory CowLab. 5) Do your lab work in that folder. Use your googlefu skills to find more commands. Recommended text editors include nano and joe. (If you hate yourself, you can use vi or emacs too.) You’ll also need to use the python3 program to execute Python programs. You can also use its interactive shell for testing. You can read more information about some of these commands here: https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/ https://introcs.cs.princeton.edu/java/15inout/linux-cmd.html History of Command Line Names (Just for Fun) In case you are wondering… nano is a free-software version of a program called pico, which is the stand-alone editor for Pine at the command line. The pine email program was an alternative version of Elm – you see, Pine Is Not Elm. The elm program was an earlier email manager. (If you think my jokes are bad, you cannot fathom the depths of terrible humor present in computer science and engineering! This is but the beginning of a terrible humor journey.) Specification Students will construct one module which (cowsay) which will contain a main() method as the entry point (for command line execution) and a data class (Cow). Note: heiferfactory.py is provided for you; your code must use this module to create cow objects. All attributes / methods must be private unless noted in the specification! Provided For Students – heiferfactory get_cows() -> list[Cow] Returns an array of cow objects from the built-in data set. This will call the Cow constructor and set_image() methods of the cow class to properly initialize new cow objects uniquely for each data set. Entry Point Your program must accept command line arguments. Command line arguments are captured as part of the args variable in the built-in sys module. (Review lecture slides for examples!) The command line arguments that must be supported are as follows: python3 cowsay.py -l Lists the available cows (this is “dash ell”!) python3 cowsay.py MESSAGE Prints out the MESSAGE using the default COW python3 cowsay.py -n COW MESSAGE Prints out the MESSAGE using the specified COW If a user calls for a cow that does not exist, the program should print out “Could not find [COWNAME] cow!” Output Samples Suggested Methods The following methods are suggested to make development easier, but are not required: _list_cows(cows: list[Cow]) Displays the list of available cows from an array of Cow objects. _find_cow(name: str, cows: list[Cow]) Given a name and an array of Cow objects, return the Cow object with the specified name. Cow Class The Cow class facilitates the creation and use of cow objects by providing the following methods (which students must implement): __init__(self, name: str) This method should be the only constructor for this class. There should not be a default constructor! get_name(self) -> str Returns the name of the cow. get_image(self) -> str Returns the image used to display the cow (after the message). set_image(self, _image: str) Sets the image used to display the cow (after the message). >python3 cowsay.py I am a potato! I am a potato! ^__^ (oo)_______ (__) )/ ||—-w | || || >python3 cowsay.py -l Cows available: heifer kitteh >python3 cowsay.py -n ninja WUT Could not find ninja cow! >python3 cowsay.py -n kitteh I am pritteh. I am pritteh. (“`-‘ ‘-/”) .___..–‘ ‘ “`-._ ` *_ * ) `-. ( ) .`-.__. `) (_Y_.) ‘ ._ ) `._` ; “ -. .-‘ _.. `–‘_..-_/ /–‘ _ .’ ,4 ( i l ),-” ( l i),’ ( ( ! .-‘ Submissions NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission! Files: cowsay.py cow.py Method: Submit on Zybooks Sample Output >python3 cowsay.py Hello World! Hello World! ^__^ (oo)_______ (__) )/ ||—-w | || || >python3 cowsay.py -n kitteh Hello World! Hello World! (“`-‘ ‘-/”) .___..–‘ ‘ “`-._ ` *_ * ) `-. ( ) .`-.__. `) (_Y_.) ‘ ._ ) `._` ; “ -. .-‘ _.. `–‘_..-_/ /–‘ _ .’ ,4 ( i l ),-” ( l i),’ ( ( ! .-‘ >python3 cowsay.py -l Cows available: heifer kitteh >python3 cowsay.py -n ninja Hello world! Could not find ninja cow! >python3 cowsay.py Hello -n kitteh Hello -n kitteh ^__^ (oo)_______ (__) )/ ||—-w | || ||

$25.00 View

[SOLVED] Cop3504c lab 01: scientific calculator

Overview In this project students will build a command-line scientific calculator. The program will display a menu of options including several arithmetic operations and options to clear the result, display statistics, and exit the program. The project’s goal is to provide students with practice in looping, type conversion, and data persistence. Specification The program must have the main() function as the entry point, which must only run if invoked directly – i.e., by checking __name__. There should be no global variables. All output should go to standard output unless otherwise specified. When the program starts it should display a menu, prompt the user to enter a menu option, and read a value: Current Result: 0.0 Calculator Menu ————— 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 1 If an option with operands (1-6) is selected, the program should prompt for and read floating point numbers as follows: Enter first operand: 89.1 Enter second operand: 42 Once the two operands have been read, the result should be calculated and displayed, along with the menu: Current Result: 131.1 Calculator Menu ————— … Operational Behavior This calculator includes multiple behaviors that are unique depending on the input and operation specified; they are detailed in this section. Results should be displayed to default precision except where specified. Exponentiation For exponentiation, the first operand should be used as the base and the second as the exponent, i.e.: If the first operand is 2 and the second is 4… 24 = 16 Logarithm For logarithms, the first operand should be used as the base and the second as the yield, i.e.: If the first operand is 2 and the second is 4… log24 = 2 Displaying the Average As the program progresses, it should store the total of all results of calculation and the number of calculations. Note that this does not include the starting value of 0! The program should display the average of all calculations as follows: Sum of calculations: 101.3 Number of calculations: 2 Average of calculations: 50.15 Note that the average calculation should show a maximum of two decimal places. The program should immediately prompt the user for the next menu option (without redisplaying the menu). If no calculations have been performed, this message should be displayed: Error: No calculations yet to average! Extra Credit Using Results of Calculation You can earn 5% extra credit on this project by allowing the user to use the previous result in an operation. To add this feature, allow the user to enter the word “RESULT” in place of an operand; if the user does so, the program should replace this operand with the result of the previous calculation (or zero if this is the first calculation): Enter first operand: 89.1 Enter second operand: RESULT Submissions NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission! File: calculator.py Method: Submit on ZyLabs Do not submit any other files! Sample Output Current Result: 0.0 Calculator Menu ————— 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 7 Error: No calculations yet to average! Enter Menu Selection: 1 Enter first operand: 0.5 Enter second operand: -2.5 Current Result: -2.0 Calculator Menu ————— 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 5 Enter first operand: -2.0 Enter second operand: -2.0 Current Result: 0.25 Calculator Menu ————— 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation For EC, replace with RESULT 6. Logarithm 7. Display Average Enter Menu Selection: 6 Enter first operand: 2 Enter second operand: 0.5 Current Result: -1.0 Calculator Menu ————— 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 7 Sum of calculations: -2.75 Number of calculations: 3 Average of calculations: -0.92 Enter Menu Selection: -10 Error: Invalid selection! Enter Menu Selection: 0 Thanks for using this calculator. Goodbye!

$25.00 View

[SOLVED] Cop3504c lab 04: time complexity & profiling

Overview This project is designed to familiarize students with “Big-O” notation through the algorithm analysis. Algorithms have an associated “Big-O” notation that describes how they run according to the input size. This models how fast the number of calculations grows as the size of the input grows larger. Programs with low growth rates are preferred because, no matter the size of the input, the program will handle it in a timely manner. In this lab exercise, students will compare two different search algorithms by timing them reflecting on how their time complexities compare to their runtimes. Specification You will write a main method and two static methods implementing binary and linear search algorithms. The linear search will step through the elements one at a time until the correct element is found; the binary search will operate on a pre-sorted set and use this knowledge to divide the search space in half at each step. Students are recommended to review the algorithms listed in their textbooks, as they are implemented directly. Provided Implementation Students are provided with the stringdata module. It contains a single data element: dataset: tuple(str) This tuple is the complete set of possible lowercase 5 character strings (containing 17,576 entries). Student Implementation Students will implement the analyzer module with a main entry point and two search methods as follows. Entry Point (main) This module will have a main() function which will execute if the module is directly invoked. The main function should complete the following steps, documenting results and answer questions in the write-up: 1) Access the data set from the stringdata module (via the dataset value). 2) Search for “not_here” using both algorithms. Capture the time each method requires to execute. 3) Search for “mzzzz” using both algorithms. Capture the time each method requires to execute. 4) Search for “aaaaa” using both algorithms. Capture the time each method requires to execute. Search Methods linear_search(container: tuple(str), element: str) -> int Uses linear search to find specified element in container. Returns index of element, or -1 if not found. binary_search(container: tuple(str), element: str) -> int Uses binary search to find specified element in container. Returns index of element, or -1 if not found. Timing your Methods To time your methods, use the time() function in Python’s time module – i.e., time.time(). It reports the time in seconds as a floating-point number. 1) Capture the begin time using time.time(). 2) Run the method. 3) Immediately after running, capture the ending time. 4) Subtract the beginning time from the ending time; display it to the screen. NOTE: You should take a screenshot of the results for each run of each method. Report In your report, include the screenshots (mentioned above) for each run of each method, along with the answers to these questions: 1) Why is a search for “not_here” the worst-case for linear search and binary search? 2) Why is a search for “mzzzz” the average-case for linear search? 3) Why is a search for “aaaaa” the best-case for linear search? 4) How do the results you saw compare to the Big-O complexity for these algorithms? 5) Why do the binary search results appear so similar, while the linear search results are so divergent? Submissions Files: analyzer.py, Lab04-Report.pdf Method: Submit on Canvas

$25.00 View

[SOLVED] Cop3504c lab 02: find four game

Overview This lab is designed to introduce students to 2D arrays by recreating the game Find Four (brand name “Connect Four”). This will require students to loop through and manipulate sequential data structures. Specification The program should be driven by the findfour module and its functions. When started, the program should display a welcome message, then ask the user for a width and height of the playing board. Once the user has entered the dimensions, the player’s chips should be displayed, followed by the empty board, and the first player should be prompted for a move. Gameplay Players take turns adding chips to the board, which drop to the lowest open row. Once one player achieves four vertical or horizontal chips in a row (not diagonal), that player wins. Play proceeds as follows. Data Storage Elements in the container should be accessible via row-major indexing (board[row][column]). In addition, the data should be stored so that row zero is the bottom of the board, i.e.: Row 3 x . . . . Row 2 x . . . . Row 1 x . o . . Row 0 x o x o o Make sure you test as you complete this assignment; otherwise, the unit tests used for evaluation will fail! Welcome to Find Four! ——————— Enter height of board (rows): 4 Enter width of board (columns): 5 _________ |. . . . .| |. . . . .| |. . . . .| |. . . . .| ——— Player 1: x Player 2: o Player 1 – Select a Column: _ The first player selects a column, and the new board is displayed. The next player is prompted. Player 1 – Select a Column: 0 _________ |. . . . .| |. . . . .| |. . . . .| |x . . . .| ——— Player 2 – Select a Column: _ Play continues to alternate until one player wins… Player 1 – Select a Column: 0 _________ |x . . . .| |x . . . .| |x . o . .| |x o x o o| ——— Player 1 won the game! …or until there is a draw. Player 1 – Select a Column: 0 _________ |o x o x o| |x o o x x| |x o o o x| |x o x o x| ——— Draw game! Players tied. Error Handling This assignment requires students to deal with user error and handle malformed input. The number of columns and rows must be in the range [4, 25]. Note: error handlings should be handled during input, and not in the method proscribed to update the board (see Functions section). The program must handle error cases as follows. Invalid Dimensions Invalid Column Entry Required Functions get_initial_board(rows: int, columns: int) -> list[list[str]] Returns a list of size rows, where each entry is itself a list of size columns, where each entry contains the value ‘.’. print_board(board: list[list[str]]) Prints a copy of the board, where board is a list of list objects, each entry a one-character str object. insert_chip(board: list[list[str]], column: int, chip: str) -> int Places a chip in the column of the board of the chip type. This method should find the next available spot in that column, if any. This method returns the row in which the chip settles. is_win_state(chip: str, board: list[list[str]], row: int, column: int) -> bool This method checks if the player represented by specified chip type has won the game by looking on the board at the position (row, column). If this is a win for the player, returns True; otherwise, returns False. is_board_full(board: list[list[str]]) -> bool This method checks if the board is full. If it is full, returns True; otherwise, returns False. Submission NOTE: Output must match example output exactly. Otherwise, your submission will not receive full credit! Files: FindFour.py Method: Submit on ZyLabs Welcome to Find Four! ——————— Enter height of board (rows): 1 Error: height must be at least 4! Enter height of board (rows): -1 Error: height must be at least 4! Enter height of board (rows): 42 Error: height can be at most 25! Enter height of board (rows): _ Welcome to Find Four! ——————— Enter height of board (rows): 5 Enter width of board (columns): 9001 Error: width can be at most 25! Enter width of board (columns): 3 Error: width must be at least 4! Enter width of board (columns): wUT Error: not a number! Enter width of board (columns): _ Player 2 – Select a Column: 0 _________ |o . . . .| |x . . . .| |x x o . .| |x o x o o| ——— Player 1 – Select a Column: 0 Error: column is full! Player 1 – Select a Column: _ Player 2 – Select a Column: 0 _________ |o . . . .| |x . . . .| |x x o . .| |x o x o o| ——— Player 1 – Select a Column: 5 Error: no such column! Player 1 – Select a Column: _ Player 2 – Select a Column: 0 _________ |o . . . .| |x . . . .| |x x o . .| |x o x o o| ——— Player 1 – Select a Column: fOo Error: not a number! Player 1 – Select a Column: _ Sample Output Welcome to Find Four! ——————— Enter height of board (rows): 2 Error: height must be at least 4! Enter height of board (rows): 4 Enter width of board (columns): 5 _________ |. . . . .| |. . . . .| |. . . . .| |. . . . .| ——— Player 1: x Player 2: o Player 1 – Select a Column: `0 Error: not a number! Player 1 – Select a Column: 0 _________ |. . . . .| |. . . . .| |. . . . .| |x . . . .| ——— Player 2 – Select a Column: 5 Error: no such column! Player 2 – Select a Column: 3 _________ |. . . . .| |. . . . .| |. . . . .| |x . . o .| ——— Player 1 – Select a Column: 0 _________ |. . . . .| |. . . . .| |x . . . .| |x . . o .| ——— Player 2 – Select a Column: -1 Error: no such column! Player 2 – Select a Column: 1 _________ |. . . . .| |. . . . .| |x . . . .| |x o . o .| ——— Player 1 – Select a Column: 0 _________ |. . . . .| |x . . . .| |x . . . .| |x o . o .| ——— Player 2 – Select a Column: 4 _________ |. . . . .| |x . . . .| |x . . . .| |x o . o o| ——— Player 1 – Select a Column: 2 _________ |. . . . .| |x . . . .| |x . . . .| |x o x o o| ——— Player 2 – Select a Column: 2 _________ |. . . . .| |x . . . .| |x . o . .| |x o x o o| ——— Player 1 – Select a Column: 0 _________ |x . . . .| |x . . . .| |x . o . .| |x o x o o| ——— Player 1 won the game! Process finished with exit code 0

$25.00 View

[SOLVED] Project 2 cda 4102 / cda 5155: fall 2025

In this project you will create a simulator for a pipelined processor. Your simulator should be capable of loading a RISC-V text file and generate the cycle-by-cycle simulation of the RISC-V code. It should also produce/print the contents of registers, queues, and memory data for each cycle. Please see the sample input file (sample.txt) and simulation output (sample_simulation.txt) from the project 2 assignment. You do not have to implement any exception or interrupt handling for this project. We will use only valid testcases that will not create any exceptions. For example, test cases will not try to execute data (from data segment) as instructions, or load/store data from instruction segment. Similarly, there will not be any invalid opcodes, less than 32-bit instructions, etc. Please go through this document first, and then view the sample input/output files in the project assignment, before you start implementing the project. Please develop your project in one source file (written in C, C++, Java, or Python) to avoid the stress of combining multiple files before submission and making sure it still works correctly. Please follow the Submission Policy which is at the end of this document to submit your source file. Your RISC-V simulator (with executable name as Vsim) should accept an input file (inputfilename.txt) in the following command format and produce output file (simulation.txt) that contains the simulation trace. In this project, you do not have to produce disassembly file. Vsim inputfilename.txt Correct handling of the sample input file (with possible different data values) will be used to determine 60% of the credit. The remaining 40% will be determined from other test cases that you will not have access prior to grading. Please construct your own sample input files to further test your simulator. 1. Instruction Format The instruction format and other details (e.g., starting address) remain the same as Project 1. 2. Pipeline Description The entire pipeline is synchronized by a single clock signal as shown in Figure 1. We use the terms “the end of the current (previous) cycle” and “the beginning of the next (current) cycle” in the following discussion. Both refer to the rising edge of the clock signal, i.e., the end of a cycle is followed immediately by the beginning of the next cycle. Figure 1: The end of the previous (last) clock cycle and the beginning of the current (next) clock cycle point to the same rising edge. 2 Figure 2 shows the pipeline. The white boxes represent the functional units, the blue boxes represent queues between the units, the yellow boxes represent registers, and the green one is the memory unit. In the remainder of this section, we describe the functionality of each of the units/queues/memories in detail. 2.1 Functional Units Instruction Fetch/Decode (IF): Instruction Fetch/Decode unit can fetch and decode at most two instructions at each cycle (in program order). The unit should check all the following conditions before it can fetch further instructions. • If the fetch unit is stalled at the end of last cycle, no instruction can be fetched at the current cycle. The fetch unit can be stalled due to a branch instruction. • If there is no empty slot in the Pre-issue queue at the end of the last cycle, no instruction can be fetched at the current cycle. Normally, the whole fetch-decode operation can be finished in 1 cycle. The decoded instruction will be placed in Pre-issue queue before the end of the current cycle. If a branch instruction is fetched, the fetch unit will try to read all the necessary registers to calculate the target address. If all the registers are ready (or target is immediate), it will update PC before the end of the current cycle. Otherwise, the unit is stalled until the required registers are available. In other words, if registers are ready (or immediate target value) at the end of the last cycle, the branch does not introduce any penalty. There are two possible scenarios when a branch instruction (jal, beq, bne, blt) is fetched along with another instruction. The branch can be the first instruction or the last instruction in the pair (remember, up to two instructions can be fetched per cycle). When a branch instruction is fetched with its next (in-order) instruction (first scenario), the next instruction will be discarded immediately (needs to be re-fetched again based on the branch outcome). When the branch is the last instruction in the pair (second scenario), both are decoded as usual. Note that the register accesses are synchronized. The value read from the register file in the current cycle is the value of corresponding register at the end of the previous cycle. In other words, any functional units cannot obtain the new register values written by WB in the same cycle. When a break instruction is fetched, the fetch unit will not fetch any more instructions. MEMORY IF Pre-Issue (4 entries) Issue Pre-ALU2 (1 entry) MEM ALU2 Post-MEM (1 entry) Post-ALU2 (1 entry) WB PC Register File (32 Registers) Control Unit (Scoreboard) Pre-ALU1 (2 entries) ALU1 Pre-MEM (1 entry) Pre-ALU3 (1 entry) ALU3 Post-ALU3 (1 entry) Figure 2: Pipelined Architecture (number of queue entries are shown in brackets) 3 The branch instructions and break instruction will not be written to Pre-issue queue. It is important to note that we still need free entries in the pre-issue queue at the end of last cycle before the fetch unit fetches them, because the fetch cannot predict the types of instructions before fetching and decoding them. Issue: Issue unit follows the basic Scoreboard algorithm to read operands from Register File and issue instructions when all the source operands are ready. It can issue at most three instructions out-of-order per cycle. It can send at most one load or store (lw, sw) instruction per cycle to the Pre-ALU1 queue, at most one arithmetic (add, sub, addi) instructions per cycle to the Pre-ALU2 queue, and at most one logical (and, or, andi, ori, sll, sra) instructions per cycle to the Pre-ALU3 queue. When an instruction is issued, it is removed from the Pre-issue queue before the end of current cycle. The issue unit searches from entry 0 to entry 3 (in that order) of Pre-issue queue and issues instructions if: • No structural hazards (the corresponding queue, i.e., Pre-ALU1, Pre-ALU2, or Pre-ALU3, has empty slots at the end of the last cycle). The issue unit should not speculate whether there will be an empty slot at the end of the current cycle. • No RAW or WAW hazards with active instructions (issued but not finished, or earlier not-issued instructions). • If two instructions are issued in a cycle, you need to make sure that there are no WAW or WAR hazards between them. • No WAR hazards with earlier not-issued instructions. • For MEM instructions, all the source registers are ready at the end of the last cycle. • The load instruction must wait until all the previous stores are issued. • The stores must be issued in order. ALU1: ALU1 handles the calculation of address for memory (lw, sw) instructions. ALU1 can fetch one instruction each cycle from the Pre-ALU1 queue (the oldest one), removes it from the Pre-ALU1 queue (at the beginning of the current cycle) and computes it. The instruction and its result will be written into the Pre-MEM queue at the end of the current cycle. Note that ALU1 starts execution even if the Pre-MEM queue is occupied (full) at the beginning of the current cycle. This is because MEM is guaranteed to consume (remove) the entry from the Pre-MEM queue before the end of the current cycle. ALU2: ALU2 handles the calculation of all arithmetic (add, sub, addi) instructions. All the instructions take one cycle. The ALU2 can fetch one instruction each cycle from the Pre-ALU2 queue, removes it from the Pre-ALU2 queue (at the beginning of the current cycle) and compute it. The instruction and its result will be written into the Post-ALU2 queue at the end of the current cycle. Note that ALU2 starts execution even if the Post-ALU2 queue is occupied (full) at the beginning of the current cycle. This is because WB is guaranteed to consume (remove) the entry from the Post-ALU2 queue before the end of the current cycle. ALU3: ALU3 handles the calculation of all logical (and, or, andi, ori, sll, sra) instructions. All the instructions take one cycle. The ALU3 can fetch one instruction each cycle from the Pre-ALU3 queue, removes it from the Pre-ALU3 queue (at the beginning of the current cycle) and compute it. The instruction and its result will be written into the Post-ALU3 queue at the end of the current cycle. Note that ALU3 starts execution even if the Post-ALU3 queue is occupied at the beginning of the current cycle. 4 This is because WB is guaranteed to remove the entry from the Post-ALU3 queue before the end of the current cycle. MEM: The MEM unit handles lw and sw instructions. It reads from Pre-MEM queue. For lw instruction, MEM takes one cycle to read the data from memory. When a lw instruction finishes, the instruction with destination register id and the data will be written to the Post-MEM queue before the end of the current cycle. Note that MEM starts execution even if the Post-MEM queue is occupied (full) at the beginning of the current cycle. This is because WB is guaranteed to consume (remove) the entry from the Post-MEM queue before the end of the current cycle. For sw instruction, MEM also takes one cycle to finish (write the data to memory). When a sw instruction finishes, nothing would be sent to Post-MEM queue. WB: WB unit can execute up to three writebacks in one cycle consisting of one from Post-MEM queue (if any), one from Post-ALU2 queue (if any), and one from Post-ALU3 queue (if any). It updates the Register File based on the content of Post-ALU2, Post-ALU3, and Post-MEM queue (lw). The update finishes before the end of the cycle. The new value will be available at the beginning of the next cycle. 2.2 Storage Locations (Queues/PC/Registers) Program Counter (PC): Records the address of the next instruction to fetch (should be initialized to 256) Pre-issue Queue: Pre-Issue Queue has 4 entries; each entry can store one instruction. The instructions are sorted by their program order, the entry 0 always contains the oldest and the entry 3 contains the newest. Pre-ALU1 queue: The Pre-ALU1 queue has two entries. Each entry can store one memory (LW or SW) instruction with its operands. The queue is managed as FIFO (in-order) queue. Pre-ALU2 queue: The Pre-ALU2 queue has one entry. Each entry can store one arithmetic (add, sub, addi) instruction with its operands. Pre-ALU3 queue: The Pre-ALU3 queue has one entry. Each entry can store one logical (and, or, andi, ori, sll, sra) instruction with its operands. Post-ALU2 queue: This queue has one entry. This entry can store one instruction with destination register id and the result. Post-ALU3 queue: This queue has one entry. This entry can store one instruction with destination register id and the result. Pre-MEM queue: The Pre-MEM queue has one entry. This entry can store one memory instruction (lw, sw) with its operands. Post-MEM queue: Post-MEM queue has one entry that can store one lw instruction with destination register id and data. Register File: There are 32 registers. Assume that there are sufficient read/write ports to support all kinds of read write operations from different functional units. Fetch unit reads Register File for branch instruction with register operands whereas Issue unit reads Register File for any non-branch instructions with register operands. 5 2.3 Notes on Pipelines 1. In reality, simulation continues until the pipeline is empty. However, for this project, the simulation finishes when the break instruction is fetched. In other words, the last clock cycle that you print in the simulation output is the one where break is fetched (shown in the “Executed” field). In other words, there may be unfinished instructions in the pipeline when you stop the simulation (see the sample_simulation.txt to see how it ended early). 2. No data forwarding. 3. No delay slot will be used for branch instructions. 4. Issue unit checks structural hazards (does not issue instructions unless its output buffers have empty slots at the beginning of the current cycle). However, four units (ALU1, ALU2, ALU3, and MEM) ignore structural hazards (starts execution even if the output buffer is full at the beginning of the current cycle since they are guaranteed to be removed before the end of the cycle). 5. Different instructions take different stages to finish. a. jal, break, beq, bne, blt: only IF b. sw: IF, Issue, ALU1, MEM c. lw: IF, Issue, ALU1, MEM, WB d. add, sub, addi: IF, Issue, ALU2, WB e. and, or, andi, ori, sll, sra: IF, Issue, ALU3, WB 3. Output Format For each cycle, print the whole state of the processor and the memory at the end of each cycle. If any entry in a queue is empty, no content for that entry should be printed. The instruction should be printed as in Project 1. 20 hyphens and a new line Cycle : IF Unit: Waiting: [instruction waiting for its operand] Executed: [instruction executed in this cycle] Pre-Issue Queue: Entry 0: [instruction] Entry 1: [instruction] Entry 2: [instruction] Entry 3: [instruction] Pre-ALU1 Queue: 6 Entry 0: [instruction] Entry 1: [instruction] Pre-MEM Queue: [instruction] Post-MEM Queue: [instruction] Pre-ALU2 Queue: [instruction] Post-ALU2 Queue: [instruction] Pre-ALU3 Queue: [instruction] Post-ALU3 Queue: [instruction] < blank_line > Registers x00:< tab >< int(x0) >< tab >< int(x1) >..< tab >< int(x7) > x08:< tab >< int(x8) >< tab >< int(x9) >..< tab >< int(x15) > x16:< tab >< int(x16) >< tab >< int(x17) >..< tab >< int(x23) > x24:< tab >< int(x24) >< tab >< int(x25) >..< tab >< int(x31) > Data < firstDataAddress >:< tab >< display 8 data words as integers with tabs in between > ….. < continue until the last data word > Display all register/memory values in signed decimal format (e.g., 4 or -4). Immediate values in instructions should be preceded by a “#” symbol and printed in signed decimal format (e.g., #4 or #-4). Because we will be using “diff –w -B” to check your output versus the expected outputs, please follow the output formatting. Mismatches will be treated as wrong output and will lead to score penalty. 4. Submission Policy Please follow the submission policy outlined below. There can be up to 10% score penalty based on the nature of submission policy violations. 1. Please develop your project in one source file. In other words, you cannot submit your project if you have designed it using multiple source files. Please add “.txt” at the end of your filename. Your file name must be Vsim (e.g., Vsim.c.txt or Vsim.cpp.txt or Vsim.java.txt or Vsim.py.txt). On top of the source file, please include the sentence: /* On my honor, I have neither given nor received unauthorized aid on this assignment */. Please do not worry about if eLearning (Canvas) adds some tag to the file name when you make multiple submissions. 2. Please test your submission. These are the exact steps we will follow too. o Download your submission from eLearning (ensures that your upload was successful). 7 o Remove “.txt” extension (e.g., Vsim.c.txt should be renamed to Vsim.c). We understand eLearning may download a PDF file for you, but it shows up correctly on our side. o Login to thunder.cise.ufl.edu or storm.cise.ufl.edu using your Gatorlink login and password. Then you use putty and winscp or other tools to login. Ideally, if your program works on any Linux machine, it should work when we run them. However, if you get correct results on a Windows or MAC system, we may not get the same results when we run on storm or thunder. To avoid this headache and time waste, we strongly recommend that you test your program on a CISE server (thunder or storm). o Please compile to produce an executable named Vsim. ▪ gcc Vsim.c –o Vsim or javac Vsim.java or g++ -std=c++17 Vsim.cpp –o Vsim o Please do not print anything on screen. o Please do not hardcode input filename, accept it as a command line option. o Please hardcode your output filename as simulation.txt. o Execute to generate simulation file and test with the correct/provided version. ▪ ./Vsim inputfilename.txt or java Vsim inputfilename.txt or ./Vsim.py inputfilename.txt or python3 Vsim.py inputfilename.txt ▪ diff –w –B simulation.txt sample_simulation.txt 3. In previous years, there were many cases where output format was different, filename was different, command line arguments were different, or e-Learning submission was missing, etc. All of these led to unnecessary frustration and waste of time for TA, instructor, and students. Please use the exact same commands as outlined above to avoid 20% score penalty. 4. You are not allowed to take or give any help in completing this project. Use of AI (e.g., ChatGPT) to develop the code, irrespective of whether it is a few lines or full project, will be treated as a violation of academic honesty. In previous years, some students violated academic honesty. We were able to establish violation in several cases – those students received “0” in the project, and their names were reported to Dean of Students Office (DSO). The penalty would be higher this year – I will give a failing score in the class. If your name is already in DSO for violation in another course, the penalty for second offence is determined by DSO. In the past, two students from my class were suspended for a semester due to repeat academic honesty violations (imply deportation for international students).

$25.00 View

[SOLVED] Project 1 cda 4102/cda 5155: fall 2025

In this project you will create a simple RISC-V simulator which will perform the following two tasks. Please develop your project in one (C, C++, Java, or Python) source file to avoid the stress of combining multiple files before submission and making sure it still works correctly. • Load a specified RISC-V text file1 and generate the assembly code equivalent to the input file (disassembler). Please see the sample input file and disassembly output in the project assignment. • Generate the instruction-by-instruction simulation of the RISC-V code (simulator). It should also produce/print the contents of registers and data memories after execution of each instruction. Please see the sample simulation output file in the project assignment. You do not have to implement any exception or interrupt handling for this project. We will use only valid testcases that will not create any exceptions. Please go through this document first, and then view the sample input/output files in the project assignment, before you start implementing the project. Instructions You can refer to RISC-V Instruction Set Architecture (riscv-ISA.pdf in the course website) to see the format for each instruction and pay attention to the following changes. For example, we introduced a break instruction, modified the opcode format, etc. In other words, you should exactly follow the details from riscv-ISA.pdf except for the changes outlined in this document. In this project, we will be using the instruction format from Figure A.23 and A.24 in the book (slide 54 of instruction.pptx). Your disassembler & simulator need to support the four categories of instructions shown in Figure 1. Category-1 Category-2 Category-3 Category-4 beq, bne, blt, sw add, sub, and, or addi, andi, ori, sll, sra, lw jal, break Figure 1: Four categories of instructions The format of Category-1 instructions is described in Figure 2. It has the same format as the S-type instruction in slide 54 in instruction.pptx except the rightmost two bits. If the instruction belongs to Category-1, the rightmost two bits (least significant bits) are always “00” preceded by 5 bits Opcode. Note that instead of using 7 bits opcode in RISC-V, we use 5 bits opcode as described in Figure 3. Assume func3 as “000”. Opcode (5 bits) 00 1 This is a text file consisting of 0/1’s (not a binary file). See the sample input file sample.txt in the project1 assignment. imm[11:5] rs2 rs1 func3 imm[4:0] Figure 2: Format of Instructions in Category-1 Please pay attention to the exact description of instruction formats and their interpretation in RISC-V instruction set. For example, in case of jal instruction, the 20-bit offset is shifted left by one bit (padded with 0 at LSB side), sign extended to form 32 bits, and then added to the address of the jal instruction to form the target address. Similarly, for beq, bne and blt instructions, the 12-bit offset is formed by concatenating bits in [31:25] with bits in [11:7], and then the 12-bit offset is shifted left by one bit, sign extended to form 32-bits, and added to the address of the current instruction to form the target address. Please note that we do not consider delay slot for this project. Instruction Opcode beq 00000 bne 00001 blt 00010 sw 00011 Figure 3: Opcode for Category-1 instructions If the instruction belongs to Category-2 which has the form “dest ← src1 op src2”, the rightmost two bits (least significant bits) are always “01” as shown in Figure 4. It has the same format as the R-type instruction in slide 54 in instruction.pptx except the rightmost two bits. Then the preceding 5 bits serve as opcode as listed in Figure 5. Assume func3 as “000” and func7 as “0000000”. Opcode (5 bits) 01 Figure 4: Format of Category-2 instructions where both sources are registers Instruction Opcode add 00000 sub 00001 and 00010 or 00011 Figure 5: Opcode for Category-2 instructions If the instruction belongs to Category-3 which has the form “dest ← src1 op immediate_value”, the rightmost two bits (least significant bits) are always “10”. It has the same format as the I-type instruction in slide 54 in instruction.pptx except the rightmost two bits. Then 5 bits for opcode as indicated in Figure 6. The instruction format is shown in Figure 7. Assume func3 as “000”. Instruction Opcode addi 00000 andi 00001 ori 00010 sll 00011 sra 00100 func7 rs2 rs1 func3 rd lw 00101 Figure 6: Opcode for Category-3 instructions Opcode (5 bits) 10 Figure 7: Format of Category-3 instructions with source2 as immediate value If the instruction belongs to Category-4, the rightmost two bits (least significant bits) are always “11”. Then 5 bits for opcode as indicated in Figure 8. The instruction format is shown in Figure 9. It has the same format as the U-type instruction in slide 54 in instruction.pptx except the rightmost two bits. Also note that the U-type format in the slide shows “imm[31:12]” but we show it as “imm[19:0]” – both means the same as 20-bit immediate value. Finally, we use the full functionality of “jal” (i.e., not assuming rd as x0). Instruction Opcode jal 00000 break 11111 Figure 8: Opcode for Category-4 instructions Opcode (5 bits) 11 Figure 9: Format of Category-4 instructions All signed numbers should be interpreted using 2’s complement arithmetic. Note that the signed numbers can be in registers, data memories or inside an instruction (e.g., the immediate field is signed for addi). Most importantly, each location (register or data memory) can be treated differently based on the context. For example, an arithmetic instruction (e.g., add) will treat the content of a register as a signed number (in 32-bit 2’s complement arithmetic), whereas a logical operation (e.g., and) will treat the same register content as an unsigned number (sequence of bits). Please go through riscv-ISA.pdf to understand how each instruction treats its operands (signed or unsigned). Assume that all unassigned register and data memory locations are 0. Sample Input/output Files Your program will be given a text input file (see sample.txt). This file will contain a sequence of 32-bit instruction words starting at address “256”. The final instruction in the sequence of instructions is always break. There will be only one break instruction. Following the break instruction (immediately after break), there is a sequence of 32-bit 2’s complement signed integers for the program data up to the end of the file. The newline character can be either “ ” (linux) or “r ” (windows). Your code should work for both cases. Please download the sample input/output files using “Save As” instead of using copy/paste of the content. Your RISC-V simulator (with executable name as Vsim) should accept an input file (inputfilename.txt) in the following command format and produce two output files in the same directory: disassembly.txt (contains disassembled output) and simulation.txt (contains the simulation trace). Please hardcode the names of the output files. Please do not hardcode the input filename. It will be specified when running your program. For example, it can be “sample.txt” or “test.txt”. Vsim inputfilename.txt imm[11:0] rs1 func3 rd imm [19:0] rd Correct handling of the sample input file (with possible different data values) will be used to determine 40% of the credit. The remaining 60% will be determined from other valid test cases that you will not have access prior to grading. It is recommended that you construct your own sample input files with which to further test your disassembler/simulator. It is okay to share your new testcases with other students in the class as long as it does not lead to similarity in the project source code. The disassembler output file should contain 3 columns of data with each column separated by one tab character (‘t’ or char(9)). See the sample disassembly file in the project1 assignment. 1. The text (e.g., 0’s and 1’s) string representing the 32-bit data word at that location. 2. The address (in decimal) of that location 3. The disassembled instruction. Note, if you are displaying an instruction, the third column should contain every part of the instruction, with each argument separated by a comma and then a space (“, ”). The simulation output file should have the following format. 20 hyphens and a new line Cycle < cycleNumber >:< tab >< instr_Address >< tab >< instr_string > < blank_line > Registers x00: < tab >< int(x0) >< tab >< int(x1) >…< tab >< int(x7) > x08: < tab >< int(x8) >< tab >< int(x9) >…< tab >< int(x15) > x16: < tab >< int(x16) >< tab >< int(x17) >…< tab >< int(x23) > x24: < tab >< int(x24) >< tab >< int(x25) >…< tab >< int(x31) > < blank_line > Data < firstDataAddress >: < tab >< display 8 data words as integers with tabs in between > ….. < continue until the last data word > Display all integer values in decimal. Immediate values should be preceded by a “#” symbol. Note that some instructions take signed immediate values while others take unsigned immediate values. You will have to make sure you properly display a signed or unsigned value depending on the context. Because we will be using “diff –w -B” to check your output versus the expected outputs, please follow the output formatting. Mismatches will be treated as wrong output and will lead to score penalty. The project assignment contains the following sample programs/files to test your disassembler/simulator. • sample.txt : This is the input to your program. • sample_disassembly.txt : This is what your program should produce as disassembled output. • sample_simulation.txt : This is what your program should output as simulation trace. Submission Policy: Please follow the submission policy outlined below. There can be up to 20% score penalty based on the nature of submission policy violations. 1. Please develop your project in one source file. In other words, you cannot submit your project if you have designed it using multiple source files. Please add “.txt” at the end of your filename. Your file name must be Vsim (e.g., Vsim.c.txt or V.cpp.txt or V.java.txt or Vsim.py.txt). 2. Please test your submission. These are the exact steps we will follow too. o Download your submission from eLearning (ensures your upload was successful). o Remove “.txt” extension (e.g., Vsim.c.txt should be renamed to Vsim.c) o Login to any CISE linux machine (e.g., thunder.cise.ufl.edu or storm.cise.ufl.edu) using your Gatorlink login and password. Then you use putty and winscp or other tools to login. Ideally, if your program works on any Linux machine, it should work when we run them. However, if you get correct results on a Windows or MAC system, we may not get the same results when we run on storm or thunder. To avoid this headache and time waste, we strongly recommend that you should test your program on thunder or storm server. Please see the notes below on accessing CISE machines. o Please compile to produce an executable named Vsim. ▪ gcc Vsim.c –o Vsim or javac Vsim.java or g++ -std=c++17 Vsim.cpp –o Vsim o Please do not print anything on screen. o Please do not hardcode input filename, accept it as a command line option. You should hardcode your output filenames. Execution should always produce disassembly.txt and simulation.txt irrespective of the input filename. o Execute to generate disassembly and simulation files and test with correct/provided ones ▪ ./Vsim inputfilename.txt or java Vsim inputfilename.txt or ./Vsim.py inputfilename.txt or python3 Vsim.py inputfilename.txt ▪ diff –w –B disassembly.txt sample_disassembly.txt ▪ diff –w –B simulation.txt sample_simulation.txt 3. In previous years, there were many cases where output format was different, filename was different, command line arguments were different, or e-Learning submission was missing, etc. All of these led to un-necessary frustration and waste of time for TA, instructor and students. Please use the exactly same commands as outlined above to avoid 20% score penalty. 4. You are not allowed to take or give any help in completing this project. Use of AI (e.g., ChatGPT) to develop the code, irrespective of whether it is a few lines or full project, will be treated as a violation of academic honesty. In previous years, some students violated academic honesty. We were able to establish violation in several cases – those students received “0” in the project, and their names were reported to Dean of Students Office (DSO). The penalty would be higher this year – I will give a failing score in the class. If your name is already in DSO for violation in another course, the penalty for second offence is determined by DSO. In the past, two students from my class were suspended for a semester due to repeat academic honesty violations (imply deportation for international students). Accessing CISE Servers (storm or thunder) to run Project 1 Please ignore this section if you know how to use CISE servers (storm or thunder) to run programs. 5. Register for a CISE account using your Gatorlink account and password. https://register.cise.ufl.edu/ 6. Download PuTTY or similar shell to run your project using Linux. If you are using MAC, you can use the Terminal client. 7. Download WinSCP or similar file transfer mechanism. You can use sftp command from your MAC terminal client. 8. Once you register (step 1), you will get an email from [email protected] indicating “your account has been created”. Unless you get this email, the subsequent steps will not work. 9. Open PuTTY and login to any of the CISE servers (storm.cise.ufl.edu or thunder.cise.ufl.edu) using your Gatorlink account and password. Create a directory for your project 1 (e.g., mkdir project1). 10. Open WinSCP and login to any of the CISE servers (storm.cise.ufl.edu or thunder.cise.ufl.edu) using your Gatorlink account and password. Transfer files from your Windows directory to the directory you created (e.g., project1). 11. Go to PuTTY again and run the command from that directory (e.g., cd project1, g++ …., diff …., etc.). If your implementation is correct, ‘diff’ command (e.g., diff -w -B simulation.txt correct_simulation.txt) should not provide any output. If your project 1 runs perfectly on VSCode, but it produces mismatches on CISE servers (storm or thunder), here is a potential fix. 12. Login to Storm or Thunder, go to the testing directory. 13. Perform dos2unix on all three input files. Make sure you have the write permissions for these three files (not read only). > dos2unix sample.txt > dos2unix sample_disassembly.txt > dos2unix sample_simulation.txt 14. Run “diff -w -B simulation.txt sample_simulation.txt” to make sure there are no differences. If the above steps fixed the differences, your code is fine (submit it). This issue relates to how Windows and Linux look at lines in a file if you implemented using C or C++. Specifically, in one case it ends with one character “ ”, and in another case it ends with “r ”. If you have used Java or Python, you may not face this problem.

$25.00 View

[SOLVED] Cpsc 1520 assignment 2: top albums filtering

For this assignment, you’re going to continue the album creator, and you’re going to implement a page where users can filter the top albums on the site, which are loaded via a RESTFUL API. Below are screenshots of the application design showing the functionality you’ll need to replicate in this assignment. Please refer to the “Required Tasks” and the “Marking Key” sections for instructions on completing this assignment. Sample Functionality Here’s an example of what the application should look when you load the page. Below is what the application should look like if you search for “dark”. Below is what the application should look like if you have a minimum rating of 4.3. Below is what it should look like if you search for “beatles” with a minimum rating of 4.2. Bonus part if you click on the “average rating” or “# of reviews” column headers it should sort by that date. Required Tasks • Part 1: Fetch the albums and render them on the page. o Create a function to get the album data from our local server. ▪ Use fetch API (using either the promise syntax or the async await syntax) in a function and return the fetched data from that function. ▪ Reassign the variables “topAlbums” and “topAlbumsFiltered” to the data that was fetched from our REST API. This can be done in the function defined above or in a separate function that should be called when the page is loaded. ▪ The data should be loaded when the page is loaded or refreshed. o Render the Albums on the page. ▪ Use map to loop through the arrays of objects that are fetched. ▪ Append the table rows to the correct part of the HTML table element. • Part 2: Albums can be filtered by the search query and the minimum rating. o Add an event listener and handler to the form. o Get the search query and minimum rating values from the inputs the same we’ve been doing throughout the course. o Create a couple of functions that will filter the minimum rating and the album names. ▪ The first function should filter the albums on either the “Album Name” or “Artist Name” properties on the album data that has been fetched. The search functionality should be case-insensitive. ▪ The second function should filter the albums on the “minimum rating” property on the talks that have been fetched. The talks shown should have a greater rating than what is entered. o Using the functions created in the last point, filter the album data and render them on the page. Quite a few examples above show you what this should look like. • Bonus Part: Sorting Average Rating and Minimum Reviews o If you click on the Average Rating and Minimum Reviews heading, it should sort from highest to lowest. • Challenge Part: (not for marks): Sort by Release Date o If you click the Release Dates heading, it should sort from highest to lowest • The code style will be specified by your instructor. Marking keyTasks Grade Marks Total Fetch and rendering. • Fetched Album data successfully, correct syntax. • Album data rendered properly. • Map used for looping over the talks. • topAlbums and topAlbumsFiltered variables are reassigned properly as the result of the fetch call back. 5 3 1 1 Loops and Filtering • Successfully added event listener and prevented the form from submitting. • Search query filtering function (not case sensitive) filters album data correctly. • Minimum Rating filtering function filters album data that has more than the value specified by the user. • The filtered album data is rendered correctly. • Filtering functions will only be called if the inputs have values. 1 5 5 3 3 Bonus • Sort columns ascending if the columns are clicked 3 Code • Code Formatting and Style • Errors running the project -3 -3 Marking Rubric Marks 5 Marks Criteria 5 Task was completed with the highest of proficiency adhering to best practices and followed subject matter guidelines all tasks were completed to a professional standard. 4 Task was completed well some minor mistakes. Well above average work shows good understanding of the task and high degree of competence 3 Satisfactory work some features missing or incorrectly implemented. Show a moderate level of understanding in the task with room for improvement. 2 Below average work. Task was poorly complete. Show understanding of the task and the requirements to implement but implementation was poorly executed. 1 Some of the task was completed. Showed a lack of understanding in the subject matter and very poorly executed 0 Not completed. Marks 3 Marks Criteria 3 Proficient shows a high degree of competence in completing task. 2 Capable above average degree of competence in completing task 1Satisfactory shows a satisfactory degree of competence in completing task. 0 Shows a limited degree of competence in completing task. Marks 1 Marks Criteria 1 Task Completed satisfactorily 0 Task was not executed.

$25.00 View

[SOLVED] Cpsc 1520 assignment 3: album search and save tool

Introduction You’ve increased the search functionality on your album creator application by having a backend implementation of the data; you’ve also increased your data This assignment will test your knowledge of the last few topics of this course by implementing this album search and save tool. Please refer back to all of the examples and all of the slides to complete this assignment, but it mainly focuses on the topics of “Arrays and loops,” “Fetch Fundamentals,” “DOM APIs and Timers,” and “NPM, Tools and ES Modules.” Note you’ll also be running a separate backend to your project that will be included, so you’ll need to run the backend and the frontend (your assignment) in different terminals and leave them running. Overview of functionality Part 1: Tab Navigation Here is a sample of part 1. When you click a single tab, you should be able to see the appropriate page. If you click “Searched Albums,” you should visit this page. Here is another sample of part 1: If you click “My Albums,” you should see the following tab. Part 2: Search by an Album with REST API backend Example for part 2: When you have implemented the search, your application should look like this if you search for “double.” Another example for part 2: When you have implemented the search, your application should look like this if you search for “Radiohead.” Note: the content should reset when you execute another search. Part 3: Add to My Albums Example for part 3: When you have searched for “double” and clicked “Add to My Albums,” the album is removed from the searched list and added to the page “My Albums,” and the button is removed. Here is the search page after the button has been clicked. If you then click the “My Albums” tab, the list item is added to the My albums section, and the button “Add to My Albums” is removed. NOTE: Duplicates are allowed in “My Albums”. Bonus Part: Saving Albums using the REST API (Do not ask your instructor this is a challenge) Every time you save to my albums (please refer to the README.md I the “assignment-3-backend” project), you’ll make a POST request to the backend saving the album data selected. You’ll need to create an endpoint for this in your “api.js” file. If you reload the page, your application should already have loaded your saved albums, and you should see the saved albums in the “albums_app_db.json” in your “assignment-3-backend”. It should look like “Part 3: Add to My Albums,” but your albums are still present when you reload the page. Required Tasks Part 0: Setup the Project • Install and run “assignment-3-backend” in a separate terminal and folder than your “assignment-3- starter”. o Extract the project and Install all of the dependencies. o Look at the “scripts” in the “package.json” file and figure out how to run the backend server, leave this command running in the background. o Look at the README.md in the “assignment-3-backend” and test the “GET Album Search Endpoint” and make a request in a REST API client of your choice. • In a separate terminal, install the packages bootstrap and parcel, and setup the required scripts using npm. o Your project should be using parcel and not live server when running the project (it won’t work anyways if you try it that way). ▪ Your scripts need to be correct and are the same as other projects you have done in class with your instructor. (This will project will be using parcel refer to the documentation if you are having trouble running the project o Once “bootstrap” is installed, import the minified “bootstrap” libraries, and import your custom CSS at the top of your “main.js” file like below. /* Import bootstrap then your css below */ import ‘bootstrap/dist/css/bootstrap.min.css’ import ‘../css/cover.css’ // Javascript imports below o Run your project. o NOTE: In your solution there should be no node_modules folder or “parcel-cache” folder. Marks will be taken off if they are included. Part 1: Tab Navigation • Get the necessary elements. o Select the elements with the Ids “album-tab-navigation,” “search-album-tab” and “myalbums-tab” and give them appropriate variable names. o From the “album-tab-navigation” element, get the nested children that are links and make separate variables for them. • Display the correct Tab. o Add an event listener on the “album-tab-navigation” element that will listen to click events. o In the event handler, get the “textContent” from the “event.target” and save that to a “tabName” variable (also display what it is for yourself so you can see what it is). o If the “tabName” is strictly equal to “Search Albums” then do the following: ▪ Add the class “active” to the search tab and remove it from the myAlbums tab ▪ Remove the class “d-none” (which is the CSS property “display: none” in “bootstrap”) from the “search-album-tab” element and add it to the “myalbums-tab” element.. o If the “tabName” is strictly equal to “My Albums” then do the following: ▪ Add the class “active” to the myAlbums tab and remove it from the search tab ▪ Remove the class “d-none” from the “my-albums-tab” element and add it to the “search-album-tab” element. Part 2: Search by an Album with REST API backend • Create a function (that takes a single value as a parameter) in the “api/album.js” file that will use fetch to call “assignment-3-backend” and return the data from that endpoint. o The function should be exported (using the named export syntax) from that file and imported into your “main.js” file. o You can use the promise syntax or the async await syntax to return the data from this function. • NOTE: you’ll need this for the following parts, but it’s strongly recommended that you test this function. • Create a function that will create a list element using your knowledge of the DOM API in the file “dom/albumElements.js.” o This function will take in one or more arguments which will be the information you need to display in the list items (depending on the implementation). Please look at the part 2 overview of functionality to see what the list item should look like. o This function should be exported (using the named export syntax) and import it in your main.js file. • In the index.js file, create an event listener to listen to the form submission event (use the form with the id search-album-form) and make the searched list items based on the searched value.The form should be prevented from submitting. o It should remove all previous items from the searched list every time you submit. o You should loop through the results and use your DOM API functions to add to the list element. ▪ NOTE: You should use your function from “api/album.js” to get the data and use your function from “dom/albumElements.js” to create the searched list item elements • Once you see results populate the page, then you should move on to the final step. Part 3: Add to My Albums • In your index.js file, create an event listener that will listen to the click events on the list element with the id “searched-albums-list.” o Check if the “event.target” includes the class “my-album-button” to ensure it’s the button in the list item that is clicked. o If the button is clicked, append this element to the list element with the id of “myalbums” and remove the button element. If you are wondering what this looks like, please look at the part 3 section in “Overview of functionality.” • NOTE: The instructor will lay out the formatting preferred. Bonus Part: Saving Albums using the REST API (Do not ask your instructor this is a challenge) • When you perform a search save, the results in an array of objects in the variable “searchedAlbums” given. • Modify your part 3 to get the search album index clicked and save the entire object to the “myAlbums” section of the backend rest API. o NOTE: Look at the “POST myAlbums Endpoint” in the README to the backend. • The second part of the bonus is that when you refresh the page in the “My Albums” section, it should load the results and populate the list with what you’ve already clicked. • NOTE: marks on this will only be given if the rest of the application is functional (subjective and based on the instructor). Marking keyTasks Grade Marks Total NPM and Packages. • Packages are installed correctly and are in the correct dependency section (dev dependency vs dependency) • Scripts are setup correctly and the source attribute in the package.json is setup correctly. • node_modules folder and parcel cache are included (if you included them it’s negative marks on your assignment) 3 3 -5 Fetch • The fetch request is takes in the search query and returns the data from the fetch request as a promise OR uses the correct async await syntax. • The function is in the correct file and exported properly. • The function is imported correctly in the index.js file 5 1 1 Dom API and Manipulation. • Tab Navigation works properly, adds and removes on the elements are properly written so that the proper sections are displayed. • Create list item element item function is in the correct file and exported correctly. • The function is imported correctly in the index.js file • The create list item element function uses ONLY DOM API to create the html structure (if innerHTML is used this section is zero.) • The create list item element returns the element created. • The form is intercepted and prevented from submitting in the index.js. 5 1 1 5 1 1 5 • The event handler of the form calls the fetch api function, create list item element and attached it to the correct area on the page. • On the recently search list items an event handler is added and using the DOM API it appends the searched albums to the my albums section and removes the button correctly. 3 Bonus • Selecting correct object and POST request executed properly and album is saved to the “myAlbums” section of the json server. • Load the “myAlbums” from the backend server when the page is loaded. 5 Code • Code Formatting and Style • Errors running the project -5 -5 Marking Rubric Marks 5 Marks Criteria 5 Task was completed with the highest of proficiency adhering to best practices and followed subject matter guidelines all tasks were completed to a professional standard. 4 Task was completed well some minor mistakes. Well above average work shows good understanding of the task and high degree of competence 3 Satisfactory work some features missing or incorrectly implemented. Show a moderate level of understanding in the task with room for improvement. 2 Below average work. Task was poorly complete. Show understanding of the task and the requirements to implement but implementation was poorly executed. 1 Some of the task was completed. Showed a lack of understanding in the subject matter and very poorly executed 0 Not completed. Marks 3 Marks Criteria 3 Proficient shows a high degree of competence in completing task. 2 Capable above average degree of competence in completing task 1Satisfactory shows a satisfactory degree of competence in completing task. 0 Shows a limited degree of competence in completing task. Marks 1 Marks Criteria 1 Task Completed satisfactorily 0 Task was not executed.

$25.00 View

[SOLVED] Cpsc 1520 assignment 1: album creator

For this assignment, you’re required to finish the application “Album Creator.” This application needs to be able to create album cards with a title, description, and some cover art. There are a few requirements in the application for albums to be valid. You need to have selected album cover art. The title needs to be between 0 and 60 characters in length. The description needs to be between 0 and 255 characters in length. Below are screenshots of your application to refer to while building this assignment. Please refer to the “Required tasks” section to see how to build this assignment. Sample Functionality Example Below are two album covers that have been successfully created. Once you add an album card with the title “My Favourites” successfully, it should look like the image below. Invalid Form Submission Example Below are some examples of what invalid form submissions should look like. Required Tasks • An Event Listener listens to the “submit” event on the form. o Prevents the form from submitting to the server. o Gets the “album title”, “album description”, and “album art” from the “elements” attribute from the “event.target” element through the “elements” property. o Validates the inputs that you got from the form element (see “Validation the inputs” below) ▪ Remove the is-invalid class from all inputs of the form that are correct. o Creates an album cover (html in the js) only if the validation is successful. o Resets the values if form validation is successful. • Validation of the inputs o An album title validation function ensures the text that it’s not empty and less than 60 characters and displays an error if it’s not valid. ▪ Adds the “is-invalid” class to the album title form input element if not valid. o An album description validation function ensures the text that it’s not empty and less than 255 characters and displays an error if it’s not valid. ▪ Adds the “is-invalid” class to the album description text form input element if not valid. o An album art validation function ensures that a gif is selected and is not empty. ▪ Adds the “is-invalid” class to the album art form input element if not valid. o An overall validation function which will take the three input elements and validate each input element using the functions above. This function should return true if valid and false if the form is not valid. • Adding an Album Card o A add album card function is created that takes three parameters the title, description, and album art values. o Adds the most recent Album will be added to the top left and shift the rest albums to the right (this functionality is shown in the example of functionality). • Other requirements o The album title input form element should be focused on (the cursor should be on this element). • Bonus o When the user changes any input o Note: No marks here if there are errors in the project. • The code style will be specified by your instructor. Marking keyTasks Grade Marks Total Form Event Listener • Javascript file linked and code can run. • Event listener added and page does not refresh. • Overall form validation function is called. • Form does not submit if not valid and returns early. • Album Covers are added only if valid. • Form element values are reset if successful. • Album title form element is focused 1 1 1 3 5 1 1 Validation of Inputs • Validates title input successfully with the validation functions (needs to be a separate function that returns true or false for full marks) • Displays the errors at the right time if they’re not valid and removes the error messages at the right time. • Validation function 5 5 1 Adding Album Covers to the page • Adds Album cover card successfully with the correct html using template strings. • Album art does not break and use relative file paths for the image src. • Most Recent Adds Album cover at top of the top left of the list of cards. 3 1 1 Bonus • When the user types anything in the form all elements are validated. • When the select changes after a form all elements are validated. 3 Code • Code Formatting and Style • Errors running the project -3 -3 Marking Rubric Marks 5 Marks Criteria 5 Task was completed with the highest of proficiency adhering to best practices and followed subject matter guidelines all tasks were completed to a professional standard. 4 Task was completed well some minor mistakes. Well above average work shows good understanding of the task and high degree of competence 3 Satisfactory work some features missing or incorrectly implemented. Show a moderate level of understanding in the task with room for improvement. 2 Below average work. Task was poorly complete. Show understanding of the task and the requirements to implement but implementation was poorly executed. 1 Some of the task was completed. Showed a lack of understanding in the subject matter and very poorly executed 0 Not completed. Marks 3 Marks Criteria 3 Proficient shows a high degree of competence in completing task. 2 Capable above average degree of competence in completing task 1Satisfactory shows a satisfactory degree of competence in completing task. 0 Shows a limited degree of competence in completing task. Marks 1 Marks Criteria 1 Task Completed satisfactorily 0 Task was not executed.

$25.00 View

[SOLVED] Cpsc1520 – javascript 8 exercise: classes and objects

Classes and object oriented programming is an essential of your tool box as a developer. In this assessment we’re going to set up a class in a file, export it and use it in our index JavaScript file. We’re going to create a fundamental quick racing app for fun, to understand the fundamentals of classes and objects. Exercise Step 1: Create the Class and use it in your index.js 1. Download and extract the package given. Install the packages needed using “npm install” like we’ve done in class. a. Once your packages are installed (you should be able to see the node_modules folder) you can run the code by using “npm run start”. 2. Open your “car.js” file in your folder, create a class named “Car” and export it, it should like below. import { createCarElement } from ‘../dom/car.js’ class Car { } export { Car } 3. Import the class “Car” into your index.js file so that you can use this class. We’ll be using this in later steps that you can use. 4. In your newly created “Car” class create a constructor that is going to take one parameter called “name” and add the following lines to the constructor: this.name = name this.element = createCarElement(this.name) Observe here that we’ve created two attributes on the class “name” and “element” that we can use in other methods. 5. In your car class add a new method named “addToRace” this will take one parameter named “raceElement”. In the “addToRace” method add the following lines of code. this.speed = Math.random()*2 this.distance = 0 raceElement.append(this.element) Observe here that we have created two new attributes “speed” and “distance”, we’ll use these in other methods. We also append the attribute “element” created in the previous step to the raceElement parameter that we are going to pass in when we create call this function. 6. In your index.js file in the map (where you’re looping over all of the racers) create a new variable named “car” and create a new “Car” object. a. After you have created your new car object. Call the method “addToRace” with the “race” variable so that you can add the cars to the page. b. Once you have completed the above, once you refresh your page it should like the image below. 7. The last step here is that we want to make our cars race! We’re going to do that by creating a method named “drive” in our car class that’s going to take no parameters. To simulate our racing we’re going to add the following lines in our “drive” method. let s = setInterval(()=> { this.distance += this.speed this.element.style.marginLeft = this.distance + ‘px’ if (this.distance > 500) { clearInterval(s) } }, 10) Notice that we’re continuously adding the speed to the distance, since we’re calling this every 10ms in the “setInterval” call back. We’re also stopping the cars by clearing the interval once the distance is greater than 500, if you want them to race a larger distance increase this or use percentages (this last part is totally optional). 8. The last step is in the index.js want to call our “drive” method after we’ve added cars to the race using the “addToRace” method. a. When the pulse pounding race is in action it should look like below. b. Once race is complete the cars should be on the right like below. 9. Once you’ve got this working like the above (using classes and objects of course) you can go to the following step. Exercise Step 2: Upload and Zip your site to moodle. 1. Once Complete, stop the parcel process, and delete the parcel-cache folders and node_modules folders. 2. Zip up your project and ensure that your entire project is included. 3. Submit that to moodle. Note if it’s too large then you probably have included your node_modules (you’ll get no marks if they’re included anyways because you read the Grading section below so you’ll delete it.) Grading I’ll give full marks if: • There is NO node_modules and NO .parcel_cache folders included in the project. • Everything is imported correctly. • The car class is correct which includes the constructor, the drive and the addToRace methods. • The end result looks like the following picture (when it’s in motion) If you don’t follow the instructions you’ll get a zero. There are no marks in between.

$25.00 View

[SOLVED] Cpsc1520 – javascript 7 exercise: es modules and using open-source packages for validation.

A large part of JavaScript is using the ecosystem of open-source packages that are out there. In this assessment we’re going to set up a project with parcel, use styles from bootstrap by importing it into our main.js, and use the validator.js package to validate our inputs. Exercise Step 1: Install packages using NPM and setup parcel.js 1. Open your command line and go to the folder of your extracted in-class-assessment. 2. In your terminal (in the same folder as your index.html) run the command “npm init” and just press enter until a “package.json” file is in the same folder as your index.html file. 3. Install the required packages that we’ll need for this project. In the terminal run the following commands. a. npm install validator b. npm install bootstrap c. npm install parcel — save-dev Note: You need to see this in your dependencies for your package.json file like so (except newer versions most likely): “dependencies”: { “bootstrap”: “^5.3.2”, “parcel”: “^2.10.2”, “validator”: “^13.11.0” } 4. In your package.json replace the scripts from what’s there to the following. From: “scripts”: { “test”: “echo ”Error: no test specified” && exit 1″ }, To this (remove “main” attribute in your package.json): “source”: “index.html”, “scripts”: { “start”: “parcel”, “build”: “parcel build” }, 5. When running your parcel web build with “npm run start” and opening the site at the port that parcel gives you you should see the following site. NOTE: If you’re using liveserver from vs code for the rest of this assessment it just won’t work. 6. In your “js” folder create an “main.js” file and link it in your html as follows.Note: To ensure that your main.js is built and is using it successfully you should just display something for yourself. Only after you’ve done these steps you should move to the next step. Exercise Step 2: Import your CSS into your main.js file to apply styles. 1. In your main.js import bootstrap so that you have some default styles. Referring to bootstraps’ documentation you should be able to import it (reference here) as the first thing in your main.js like so: import ‘bootstrap/dist/css/bootstrap.min.css’; Note: If everything is working successfully it should look like the image below (If it doesn’t refer back to the previous steps): 2. Using relative file paths import your signin.css file to your main.js. Once you do so your sign up form should be a little narrower and look like the screen shot below. Exercise Step 3: Use Validator.js in the event listener to display the errors. 1. Add an event listener on the “form”. a. Get all of the input elements, this would be the input for the: email address/username, password one and password two 3. Import the validator package that you installed in step 1. a. You can refer here to the documentation to see how to import validator using es6 4. Using the server side validation techniques we’ve used in the past (refer to docs here) and validator validate all of the inputs in the form. a. Validate the email using the “isEmail” function (which returns a boolean) under validators (docs here) and add/remove the “is-invalid” class when appropriate. Here’s an example of what it should ideally look like without an email. b. Validate the password one with the “isStrongPassword” function (with no options using default, refer to docs here) and add/remove the “is-invalid” class when appropriate. Here’s what it should look like with a valid email address and an invalid password: c. Validate the password two by checking if it’s equal to the first password and add/remove the “is-invalid” class when appropriate. Here’s what it should look like when the email is valid, the password one is valid but password two is not equal to password one: 5. If all of the form inputs and the user clicks submit, call the “signInSuccess” function with the email provided. The application should look like the screenshot below. Test Cases: All of these should pass. – Valid Case. o email address: [email protected] o password one: GarySteve1@ o password two: GarySteve1@ – Invalid Case: passwords don’t match, but are strong o email address: [email protected] o password one: GarySteve1@ o password two: Something1@ – Invalid Case: passwords don’t match, and are not strong o email address: [email protected] o password one: something o password two: terriblepassword – Invalid Case: passwords match, but are not strong o email address: [email protected] o password one: something o password two: something – Invalid Case: email isn’t valid. o email address: supercoolperson o password one: GarySteve1@ o password two: GarySteve1@ Exercise Step 4 – Push up your code to GitHub 1. Open the link given and accept the assignment. Your link should look something like this. Note the image will be different because you’ll accept the assignment specified. You’ll see a page like this. One you’re repo is ready the page should look like the following. 2. You should see the page below once you click on the link highlighted in blue. Click the button that says “Code.” You’ll need to select “HTTPS” unless you’ve set up “SSH” (you can also set up GitHub CLI”. Click on the copy icon once you’ve selected the proper icon. 3. Clone the repository in your console (or if you’re using GitHub Desktop) using the “git clone REPO_URL” command. And go into this folder. 4. Make your changes, then add them to staging (using “git add .”) and commit them (using “git commit -m “CHANGE THIS MESSAGE”). Once committed, push them up to GitHup (using “git push”) it should look like below. 5. If you click “Pull Requests” and then the first item called “Feedback” you should see your commit (seen at the bottom). 6. Upload the link of your repository to Moodle. Grading – The test cases should be valid or invalid based on the data provided and should match the screenshots provided. – If valid the welcome screenshot should be shown. – Grading will be either pass/fail or complete/partially complete/incomplete based on your instructor preference.

$25.00 View

[SOLVED] Cpsc1520 – javascript 6 exercise: fetch api

The Fetch API is essential to most client side JavaScript applications. In this in class exercise what you’ll be doing is you’ll be using fetch to get data and populate an application. We’ll be using the data from the Metropolitan Museum of Art https://metmuseum.github.io/ to practice getting data and reading some documentation. Exercise Step 1: Fetch and Render the objects from the Met Museum REST API 1. Create a function named “getMuseumObjectsData”, this is going to be the function that will be doing our fetch requests. a. You’ll be needing to loop through the museum objects ids so that in this function so that you can access each id. 2. In the loop that you’ve created in the previous step you’ll need to make a fetch request for each id to the “Object” endpoint of the MET Museum API. a. You’ll be using the documentation from the MET Museum REST API. Look at the documentation under “Object” (not “Objects”) at this link https://metmuseum.github.io/. Note that you can use a REST API client to ensure that you are making the correct request. b. To ensure that you’ve got the fetch request working, print out the resolved data to the console. 3. Create a function named “renderGalleryCard”. a. This function will take five parameters i. Title ii. Image iii. artistName iv. date v. wikiDataUrl b. Select the element with the class “museum-gallery” c. Loop through each contact and use the “HTML for the project” in the main.js to continuously add a templateString to the element above. d. When you call the function with the correct data the page: i. Must have the correct title matching the screenshot below ii. Must have the correct image matching the screenshot below iii. Must have the correct artist name matching the screenshot below iv. Must have the correct date matching the screenshot below v. Must have the correct wiki data url matching the screenshot below 4. Call the function “renderGalleryCard” when you resolve your fetch request in the “getMuseumObjectsData” function. 5. The final product should look like the screenshot below. Exercise Step 2 – Push up your code to GitHub 1. Open the link given and accept the assignment. Your link should look something like this. Note the image will be different because you’ll accept the assignment specified. You’ll see a page like this. One you’re repo is ready the page should look like the following. 2. You should see the page below once you click on the link highlighted in blue. Click the button that says “Code.” You’ll need to select “HTTPS” unless you’ve set up “SSH” (you can also set up GitHub CLI”. Click on the copy icon once you’ve selected the proper icon. 3. Clone the repository in your console (or if you’re using GitHub Desktop) using the “git clone REPO_URL” command. And go into this folder. 4. Make your changes, then add them to staging (using “git add .”) and commit them (using “git commit -m “CHANGE THIS MESSAGE”). Once committed, push them up to GitHup (using “git push”) it should look like below. 5. If you click “Pull Requests” and then the first item called “Feedback” you should see your commit (seen at the bottom). 6. Upload the link of your repository to Moodle. Grading I’ll give full marks if: • The code is correctly implemented as described above. • The end result looks like the following picture

$25.00 View

[SOLVED] Cpsc1520 – javascript 5 exercise: arrays and loops

Arrays are essential data structures that are used not only in JavaScript but essentially every programming language. In this exercise, you’ll be creating an array of images, rendering them to the page, and giving the ability to save images to a list. Exercise Step 1: Create the Carousel with the images. 1. Modify the “images” array with the image names in the images folder. Note: No need to include the path. 2. Create a method named “renderCarousel” that will call the function “createCarouselItem” with the correct arguments to render the items on the page. 3. Call the function “renderCarousel,” and the page should change from blank to images. a. Before calling the “renderCarousel” method: b. After calling the “renderCarousel” method: Exercise Step 2: Add to My Images 1. Observe the event listener in the JavaScript file for step 2. If you print out the “itemIndex” matches the clicked item array index in the “images” list, you see that. 2. Using array methods, check if “savedImages” array includes the image at the “itemIndex” specified. a. If it does, don’t do anything (we don’t want any duplicates here). b. If it does not, add the image name to the array using array methods. You can use some debugging techniques here to display whether the array has the item or not. Note: this means if I click the “cat” image three times I should only see it once in my list. 3. Create a function named “renderImageList.” The function will loop through the “savedImages” array and call the function “addToSavedImageList” with the correct arguments. a. Call this function after you add an item to the “savedImages” array. Note that, before calling the function, you may have to re-initialize “savedList.innerHTML”. 4. If you click the “cat” image twice and the “polar bear” image three times, the result should look like below. Exercise Step 3 – Remove items from “My Image” list. 1. Observe the “itemIndexToRemove” in the event listener on the saved list. 2. Using array methods, remove the item at the index specified from the “savedList” array. 3. Call the function “renderMyImageList” below that. 4. Once you have clicked “save Image” on the cat and the “polar bear” and then clicked “remove” on the polar bear, your page should look like below. Exercise Step 4 – Push up your code to github (accepting this assignment) 1. Open the link given and accept the assignment. Your link should look something like this. Note the image will be different because you’ll accept the assignment specified. You’ll see a page like this. One you’re repo is ready the page should look like the following. 2. You should see the page below once you click on the link highlighted in blue. Click the button that says “Code.” You’ll need to select “HTTPS” unless you’ve set up “SSH” (you can also set up GitHub CLI”. Click on the copy icon once you’ve selected the proper icon. 3. Clone the repository in your console (or if you’re using GitHub Desktop) using the “git clone REPO_URL” command. And go into this folder. 4. Make your changes, then add them to staging (using “git add .”) and commit them (using “git commit -m “CHANGE THIS MESSAGE”). Once committed, push them up to GitHup (using “git push”) it should look like below. 5. If you click “Pull Requests” and then the first item called “Feedback” you should see your commit (seen at the bottom). 6. Upload the link of your repository to Moodle. Grading I’ll give full marks if: • The test cases passed. • Images render correctly in the carousel, • Images added correctly to “My Images” when clicking “Save Image” • Images removed correctly from “My Images” when clicking “remove”. If you don’t follow the instructions you’ll get a zero. There are no marks in between.

$25.00 View

[SOLVED] Cpsc1520 – javascript 4 exercise: making decisions and forms

Validation of forms is everywhere when you create a JavaScript application and a web application in general. You want to ensure that you’re getting correct and valid information from your users so that you can (for us in the future) save this information. Exercise Step 1 – Adding a new Item to our Order 1. Link your JavaScript file in the HTML, do not change any HTML otherwise. 2. Select the form with the class “new-order-form” 3. Add an event listener on the form that will handle the “submit” event. 4. Using the event object, prevent the default action from happening 5. Assign the form elements from using the “elements” property on the “event.target” to variables with appropriate names. 6. Pass the form input values to the “addOrderItem” function given. a. If you’re ever confused about a specific variable, you can always use the console to print out the variables. The output should look something like this once you click the “Add to Order” button: Exercise Step 2 – Validating Elements of the Form 1. There’s a bug in our application. We get a blank row to our order if we submit our form with nothing in it. We only want populated rows because that is what we expect in our application. 2. Create a variable named “isFormValid” that will be assigned a Boolean. Using this variable you, either execute or do not execute the “addOrderItem” with the values from the form. 3. In the following steps, use the “isFormValid” with the validation functions “isValueNotEmpty” and “isGreaterThanFive”. 4. Validate the order item name. a. If the order item name is not an empty string, then the item name is valid. i. Remove the “is-invalid” class on the order item name using the elements’ “classList.remove” function. b. If the order item name is an empty string, then the item name is invalid. i. Add the “is-invalid” class on the order item name using the elements’ “classList.add” function. ii. Set the “isFormValid” to false. 5. Validate the order item price. a. If the order item price is not an empty string, and if it’s greater than five then the item price is valid. i. Remove the “is-invalid” class on the order item price using the elements’ “classList.remove” function. b. If the order item price is an empty string, or if the price is less than five or if then the item price is invalid. i. Add the “is-invalid” class on the order item name using the elements’ “classList.add” function. ii. Set the “isFormValid” to false. 6. Validate the order size. a. If the order size is not an empty string, then it’s in valid. i. Remove the “is-invalid” class on the order item size using the elements’ “classList.remove” function. b. If the order size is an empty string, then it’s invalid. i. Add the “is-invalid” class on the order item size using the elements’ “classList.add” function. ii. Set the “isFormValid” to false 7. Execute the “addOrderItem” function only if “isFormValid” is true. There are a couple of ways to do this, and either works. 8. You reset the values of each input on a successful form submission. 9. The functionality should look like the following result. a. Successful result b. Invalid result with all of the inputs invalid. Test Cases You might need clarification and need to know what values to test here to help you out. • Test case: form invalid o Item Name: Burger o Price: o Size: • test case: form invalid o Item Name: o Price: 18 o Size: • test case: form invalid o Item Name: pop o Price: 4 o Size: small • test case: form invalid o Item Name: o Price: o Size: Small • Test case: valid form o Item Name: pop o Price: 6 o Size: small Exercise Step 4 – Push up your code to github (accepting this assignment) 1. Open the link given and accept the assignment. Your link should look something like this. Note the image will be different because you’ll accept the assignment specified. You’ll see a page like this. One you’re repo is ready the page should look like the following. 2. You should see the page below once you click on the link highlighted in blue. Click the button that says “Code.” You’ll need to select “HTTPS” unless you’ve set up “SSH” (you can also set up GitHub CLI”. Click on the copy icon once you’ve selected the proper icon. 3. Clone the repository in your console (or if you’re using GitHub Desktop) using the “git clone REPO_URL” command. And go into this folder. 4. Make your changes, then add them to staging (using “git add .”) and commit them (using “git commit -m “CHANGE THIS MESSAGE”). Once committed, push them up to GitHup (using “git push”) it should look like below. 5. If you click “Pull Requests” and then the first item called “Feedback” you should see your commit (seen at the bottom). 6. Upload the link of your repository to Moodle. Grading I’ll give full marks if: • All of the test cases pass. • The form validates each input element separately. • An invalid form submission should look like this: • A valid form submission should look this: If you don’t follow the instructions specified you’ll get a zero. There are no marks in between.

$25.00 View