Directions:
Typing make at the command line should create executable named bitflip.
Only bitflip.c and Makefile are included in the input unless permission is given for any other files.
Code should be readable with good variable and function names.
No use of "break or continue statements" except in a switch.
Program must exit with a return code of 0 on success and an error code in other cases.
The program used getopt to parse the command line.
Whenever an error occurs on the command line the user is given the usage statement and an appropriate error message if needed.
If the -o option is used the output will go to a file named as specified without changing the filename at all otherwise it will go to stdout.
-e option works as specified using bitwise operations.
-f option works as specified using bitwise operations.
-a option works as specified using bitwise operations.
-s option works as specified using bitwise operations.
Program outputs only the original value if none of the bitwise options are included.
Write a C program called bitflip to run on ocelot which will flip bits in an unsigned integer using the binary representation of the number. The user should input the original integer value between 1 and 20000 inclusive on the command line as well as the desired options. Use an unsigned integer type uint16_t. Output is to the screen or to a file. You must use only bitwise operators for this program. You can shift bits and or use the logical bitwise operators.
usage: bitflip [-e] [-f] [-a] [-s] [-o outputfilename] intval
Output the new integer number(s) depending on which options are requested (all aperations done on the original intval). Do not use any break or continue statements other than in the switch.
- You should use getopt for this program to identify the options.
- The program will always print the starting value on the first line of output and each other value on a new line, clearly identifying it.
- If the -e option is selected then flip all even bits.
- If the -f option is selected then flip all odd bits.
- If the -a option is selected then flip all bits.
- If the -s option is selected then take the bits and switch them around from right to left. (The rightmost bit becomes the leftmost bit.
- If the -o option is selected then print the output to an output file instead of to the screen.
- If an option is included more than once, you can ignore duplicates.
The source file should have your name & Panther ID, a description and it should have the affirmation of originality included in a comment at the top.
Code should be nicely indented and commented.
Create a simple Makefile to compile your program into an executable called bitflip.
A sample of a run of the program could be something like this:
jdoe@ocelot:~/ 135% bitflip -s -a -e -f 391
Value: 391
Even bits flipped: 21714
Odd bits flipped: 43821
All bits flipped: 65144
Switched all bits: 57728
Step by stepSolved in 4 steps with 4 images
- I typed your code in exactly as it was typed in your answer and I am getting a lot of errors.arrow_forwardCreate methods "read" and "write" methods to handle the input and output to files. in Javaarrow_forwardCan you help me write a C++ Program that does the following: Create a program that reads a file containing a list of songs andprints the songs to the screen one at a time. After each song is printed,except for the last song, the program asks the user to press enter for more.After the last song, the program should say that this was the last song andquit. If there were no songs in the file to begin with, the program shouldsay that there are no songs to show and quit.The program should begin by asking the user for the name of the input file.Each song consists of a title, artist and year.In the file, each song is given on three consecutive lines.Create this program using the latest version of the class Song you created. The latest version of the class song I created is below: #include <iostream>#include <string>using namespace std;class Song {private: string Title; string Artist; int Year;public: Song() : Title("invalid"), Artist("invalid"), Year(-1) {} Song(const string…arrow_forward
- Java Program ASAP ************This program must work in hypergrade and pass all the test cases.********** Here is a working program. Please modidy this program so it passes the test cases down below. I have provided the correct test case as a screenshot. For Test Case 1 first print out Please enter the file name or type QUIT to exit:\ then you type text1.txtENTER and it displays Stop And Smell The Roses./n there needs to be nothing after that. For test case 2 first print out Please enter the file name or type QUIT to exit: then you type txt1.txtENTER then it reads out File 'txt1.txt' is not found.\n Then it didplays Please re-enter the file name or type QUIT to exit:\n after the test file is not found. then you type in text1.txt and it displays stop and smell the roses.\n. For test case 3 first print out Please enter the file name or type QUIT to exit: then you type text2.txtENTER and it displays A true rebel you are! Everyone was impressed. You'll do well to continue in…arrow_forwardcan you do it pythonarrow_forwardUsing a Counter-Controlled whileLoop Summary In this lab, you use a counter-controlled while loop in a Java program provided for you. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements. Instructions Ensure the file named Multiply.java is open. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop. Execute the program by clicking Run. Record the output of this program.arrow_forward
- -all-occurrences-of-a-substring-in-a-string/.arrow_forwardJava Program ASAP ************This program must work in hypergrade and pass all the test cases.********** Please give me a new program becausse when I upload the program to hypergrade it does not pass the test cases. It says 1 out of 4 passed. Thank you! For Test Case 1 first print out Please enter the file name or type QUIT to exit:\ then you type text1.txtENTER and it displays Stop And Smell The Roses./n there needs to be nothing after that. For test case 2 first print out Please enter the file name or type QUIT to exit: then you type txt1.txtENTER then it reads out File 'txt1.txt' is not found.\n Then it didplays Please re-enter the file name or type QUIT to exit:\n after the test file is not found. then you type in text1.txt and it displays stop and smell the roses.\n. For test case 3 first print out Please enter the file name or type QUIT to exit: then you type text2.txtENTER and it displays A true rebel you are! Everyone was impressed. You'll do well to continue in…arrow_forwardJava Program ASAP ************This program must work in hypergrade and pass all the test cases.********** The text files are located in Hypergrade. Also for test case 1 first display Please enter a string to convert to Morse code:\n then you press Enter it should print out \n. Then for test case 2 it should display Please enter a string to convert to Morse code:\n then you type abc it should print out .- -... -.-. \n For test case 3 first display Please enter a string to convert to Morse code:\n then you type This is a sample string 1234.ENTER it should print put - .... .. ... .. ... .- ... .- -- .--. .-.. . ... - .-. .. -. --. .---- ..--- ...-- ....- .-.-.- \n. This program down below does not pass the test cases as shown in the screenshot I have provided the correct test case as a screenshot too. Please modify it or create a new program so it paases the test cases. Thank you! For test case 1 it wants only Please enter a string to convert to Morse…arrow_forward
- In this assignment, you will create a Java program to search recursively for files in a directory.• The program must take two command line parameters. First parameter is the folder to search for. Thesecond parameter is the filename to look for, which may only be a partial name.• If incorrect number of parameters are given, your program should print an error message and show thecorrect format.• Your program must search recursively in the given directory for the files whose name contains the givenfilename. Once a match is found, your program should print the full path of the file, followed by a newline.• You can implement everything in the main class. You need define a recursive method such as:public static search(File sourceFolder, String filename)For each subfolder in sourceFolder, you recursively call the method to search.• A sample run of the program may look like this://The following command line example searches any file with “Assignment” in its name%java FuAssign7.FuAssignment7…arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. 1- Write code that does the following: opens an output file with the filename number_list.txt, uses a loop to write the numbers 1 through 100 to the file, then closes the file.arrow_forwardThe provided file has syntax and/or logical errors. Determine the problem and fix the program. // Program asks user to enter password // If password is not "home", "lady" or "mouse" // the user must re-enter the password using static System.Console; class DebugFive1 { static void Main() { cont string PASS1 = "home"; cont string PASS2 = "lady"; cont string PASS3 = "mouse"; string password; Write("Please enter your password "); password = Console.ReadLine(); while(password != PASS1 || password != PASS2 || password != PASS3) WriteLine("Invalid password. Please enter again. "); password = ReadLine(); WriteLine("Valid password"); } }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education