Recent Question/Assignment

1. This assignment contains 3 questions.
2. Submit one-word document and a zip file.
a. Question No. (No need to copy and paste question)
b. Problem description, data table, pseudocode or flow chart etc
c. C- program only (.c)- copy and paste your source code (not the screenshot of the code)
d. Enough screenshots of the output that shows all possible outcome.
3. Marks will be given for proper indentation and comments.
Other requirements:
• This assignment must be written in C for questions 1 and 3 and in C++ for question 2.
• Your code must have appropriate header (multiline/block) comments
• Include inline (single line) comments throughout the program describing important statements.
• Use appropriate and descriptive variable following the naming rules and conventions.
• Write a brief (no more than several pages) report, which illustrates your program design (algorithm or flowchart, identification of variables, constants) and include evidence of testing – screen shots or pasted output text of several tests, and the contents of the .c/C++ file.
• Marks will be allocated depending on the amount of original work submitted. Marks will be deducted for plagiarised and/or un-attributed work.
Qn 1. Write a complete C program
Create a text file that contains four columns and ten rows. First column contains strings values, second and third column contains integer values, and fourth column contains double values (you are free to use your own values).
Declare a structure that contains 4 elements. (you are free to use your own variables) First element should be a char array – to read first column values from the text file.
Second element should be an int value – to read second column values from the text file.
Third element should be an int value – to read second column values from the text file.
Fourth element should be a double value – to read third column values from the text file.
Declare an array of this structure with size 10 and read the contents of the text file into this array.
Then prompt the user with the following instructions:
1: Display the details of the array – call a function to display the contents of the array on screen. 2: To sort the array (you should call sort function – output of the sorting function is written onto a text file and terminal)
You should give the user the chance to sort in ascending or descending order with respect to string value.
Then you should give the user the option to select from different sorting techniques (you should write minimum two sorting algorithm functions, call the functions according to the choice the user enters – call the sorting function only after the user selects the above-mentioned options).
3: To search for a string element (Write the output on terminal)
You should give the user to select the searching technique (linear or binary – must use recursive version of the searching functions) if binary is selected call a sort function first
4: To insert these array elements into a linked list in the order of string values. Display the contents on the terminal. 5: Quit
Your complete program should have multiple files (minimum two .c files and two .h files). Give your file name as heading and then paste your code. Do not forget to show the screen shots of your text files as well.
Qn2. Write a complete C++ program
Assume you are working as a programmer in a communication field. Your task is to alter the original data before transmission. The data is an integer that contains the number of digits between two and eight (inclusive), thus the possible integers are between 10 and 99999999. You must read in an integer and complete the following stages.
Stage 1:
Your task is to modify the data for transmission according to the following set of rules.
1. If the number is a two-digit number you swap the positions of the numbers (eg: if the number is 56, altered number is 65).
2. If the number is a three digit number, digits at positions 1 and 3 are swapped.
(eg: number is 123, altered number is 321)
3. If the number is four digits or above, the following rules apply.
Replace each digit by the remainder after that digit is multiplied by 3 is divided by 10.
Stage 2: Extra protection (done only on 8 digits numbers – if the user chooses this option)
Eight-digit data contains more valuable information, so you are asked to enable extra protection if the user chooses to.
The extra protection is done on modified number in stage one by swapping the digit in position 1 with digit in position 8, digit in position 2 with digit in position 7, digit in position 3 with digit in position 6, digit in position 4 with digit in position 5.
If the modified number in stage 1 is as shown below:
2 3 4 5 6 7 8 9
The number after stage 2 will look like:
9 8 7 6 5 4 3 2
Stage 3: (Decoding)
Once the encoding stages are over, write the codes to recover your original data from the encoded data.
Qn3. Write a complete C program - you must declare and use a self-referential structure for this question
This task is to develop a software for a bookshop that handles the purchases through online. When the customer places order to buy a book, the shop will search for the specific item upon customers request in the order of first come first served basis. The books available in the shop are kept in a text file called books.txt.
At the beginning of the program the details of the books are read from books.txt and stored in a LinkedList. Then the list of the books ordered by customers is saved in a queue. Then the program should take the order from the beginning (head) of the queue and search for it in the LinkedList. If the item found in the list delete it and put this book in a stack to be able to retrieve for the last book sold.
The main() function handles all interactions with the user and other functions:
• Calls a function named readBook()which opens a text file books.txt (a sample text file is shown below) for reading and storing names of books from the file to a LinkedList in order of name (insertion should happen in alphabetical order).
• It then repeatedly calls the menu () function to display user options, get theuser selection returned by the menu() function, use a switch (or if ..else if) statement to process user request by calling appropriate function(s).
Details of options in menu function:
(1) Display the current stock of books– here you display the contents of the LinkedList
(2) Add a new book to stock – you need to insert a new book to LinkedList
(3) Display next order information – displays the next book in the order-list (first node of the queue)
(4) Display all orders – displays all nodes of the queue
(5) Add order to queue – adds new order to the end of the queue
(6) Process the next order – Processes the first order in the queue. This function searches for this book in the LinkedList and deletes (if found) from LinkedList and puts it into a stack, deletes from the queue as well.
(7) Cancel last order – It cancels the last processed order. It inserts the book (top of the stack) back into LinkedList (book is not added back into queue).
(8) Display info of last order – displays the information of the last processed order (top of the stack).
(9) Update book file – updates the books.txt with the remaining books in the list (including the books added in option2).
(10) Quit program
Sample books.txt file

Looking for answers ?

Recent Questions

Assignment 2BFA504 Semester 1, 2021Data Analytics and Data VisualizationAssignment Type: IndividualWeighting: 20%Due Date: 10th of May (Monday: 11:59 PM)Submission: Upload files on to MyLO. Click here...• Determine the level of materiality to be used for the audit of the group accounts for the year ending in 2020. Your answer should include a discussion of the nature of materiality, and a description...Assessment Details and Submission GuidelinesAssessment Type: Individual Assignment % of total: 25%Assessment Date: End of Week 07 Learning Outcomes: 1,2,3 & 4Summative: Yes Duration/Word Length: 1500...Assessment 4 Marking Rubric: Ethical Concepts Part 2 MC Quiz - Value 5%Criteria Fail Pass Credit Distinction High Distinction Weighting% (0 - 49%) (50 - 64%) (65 - 74%) (75 - 84%) (85-100%)Number of correct...EXERCISE 4To be completed by the TraineeYou must include this page with your Exercise 4 submissionAlternatively you can retype the details as a front page to your ExerciseTrainee name _________________________________________________________________________Trainee...EXERCISE 3To be completed by the TraineeYou must include this page with your Exercise 3 submissionAlternatively you can retype the details as a front page to your ExerciseTrainee name _________________________________________________________________________Trainee...EXERCISE 2To be completed by the TraineeYou must include this page with your Exercise 2 submissionAlternatively you can retype the details as a front page to your ExerciseTrainee name _________________________________________________________________________Trainee...Show All Questions