What is the public interface of counter class in section 3.1 ? How does it differ from the implementation of the class?
Submission Folder | |
Chapter 3 Practice Exercise E3.1 | |
Instructions | |
Submit this assignment as an exported archive called CounterModified Textbook ISBN NUmber : 978-1-119-05645-4 |
In: Computer Science
In C, write a function that inserts a new node by taking four arguments, a head, tail, current node, and new node pointers. If head is NULL, perform head insertion, otherwise transverse the linked list recursively by using current node pointer. Terminate when the current node points at the tail after inserting new node at tail and pointing tail at new node.
In: Computer Science
Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially:
void inputStringFromUser(char *prompt, char *s, int arraySize);
void songNameDuplicate(char *songName);
void songNameFound(char *songName);
void songNameNotFound(char *songName);
void songNameDeleted(char *songName);
void artistFound(char *artist);
void artistNotFound(char *artist);
void printMusicLibraryEmpty(void);
void printMusicLibraryTitle(void);
const int MAX_LENGTH = 1024;
You will write a program that maintains information about your personal music library using a Linked List data structure. The program will allow you to add and delete entries from your personal music library, to search your personal music library for songs by song name, and to print out the entire list of your library. This lab will be due in the week of April 1.
Your Personal Music
Library. The data in your personal music library will be stored in
memory with the use of a linked list, with one list node per song.
Each node will contain three strings: a song’s name, its artist,
and its genre (the type of music). The linked list must be kept in
sorted alphabetical order, by song name, beginning with A through Z
(i.e. increasing alphabetical order). No two songs in your personal
music library should have the same name. Your program should be
“menu” driven, with the user being offered a choice of the
following five “commands”:
• Command I. Insert a new song into the library.
The program should prompt the user for a new song name, its
artist’s name, and its genre. This information must be placed in a
new node that has been created using the malloc function (to be
clear, you must use malloc for this purpose). This node should then
be inserted at the appropriate (alphabetical) position in the
linked list. Don’t forget that the music library must be stored in
increasing order, by song name. If a node with the given song name
is already in the music library, an error message should be output,
and the new node should not be inserted into the linked list.
• Command D. Delete an entry from your the
library. The program should prompt the user for the name of the
song to be deleted, and then find and delete the node containing
that song name from the library. If no node with the given song
name is found, an error message should be output. All memory
allocated for a deleted entry must be released back to the system
using the free function. This includes not only the memory
allocated for the node, but also the strings in the node that would
have been separately allocated.
• Command S. Search for a user supplied song name
in the library. The program should print the name, artist, and
genre of the song, with each piece of information on a separate
line. If no node with the given song name is found, an error
message should be output.
• Command P. Print your personal music library, in
alphabetical order by song name. Print the song name, artist, and
genre of each song, each on a separate line. A blank line should be
printed between each song.
• Command Q. Quit the program. When the program is
given the Q command, it should delete all of the nodes in the
linked list, including all the strings contained
in each node. Deletion
means both removing from the list, but also freeing all dynamically
allocated memory using call the free function. It should then print
the (what should be an empty) linked list.
To assist you in the production of your program, we have provided
you with a file, musiclibrary.c, that contains part of the complete
program. This program is provided on the course website along with
this lab. This “skeleton” of the lab 9 program includes all of the
C statements required to implement the menu driven parts of the
program. It also includes a few helpful functions for reading data
and printing messages. You should take this file and edit it to
become your version of Lab9.c. Note, however, that you may not
change any of the code in the existing implementation of the
skeleton program, except where indicated in comments. In
particular, you must use the inputStringFromUser()
function and the prompts provided to obtain inputs from the user,
and you must use the given Node structure. In addition we strongly
recommend that you do your work for this lab in the following
way:
• Read the entire skeleton program carefully. Take note of the
provided functions for reading strings, printing the name, artist
and genre of a song, and for printing error messages. Using these
functions will make it easier for you to satisfy the exercise and
marker programs.
• Add the function for inserting a new node(the I command) into the
linked list. Your function will need to read the name, artist, and
genre of a song. Test your program by trying to insert nodes into
the linked list. Try to insert nodes with both new and duplicate
song names.
• Add a function for printing the linked list (the P command). Test
your program by inserting songs into the linked list and then
printing them out. Are the entries in the correct order? • Add a
function that searches the linked list for a given song name and
then either prints the appropriate song or, if a node is not found,
prints an error message. This is the S command.
• Add the statements that need to be executed when the Q command is
entered. These statements should delete the linked list by using
calls to the free function. To check your work, print the linked
list after the elements have been deleted. • Add a function for
deleting a song from the personal music library. It will need to
search the linked list for a given song name, delete the
appropriate node from the linked list, and then use the free
function to release the memory used to store the node, as well as
all the memory that the node uses for storing strings. If the given
song name is not found in the music library, print an error
message.
We recommend that you test your program after attempting to
complete each step. This way, if your program no longer works, you
will know which statements are causing the error. Complete each
step before moving on to the next one.
Sample Output From
Executing The Program
Here is a sample output from an execution of the program that you
are to prepare.
Personal Music Library.
Commands are I (insert), D (delete), S (search by song name), P
(print), Q (quit).
Command --> P
The music library is empty.
Command --> I
Song name --> The Shade
Artist --> Metric
Genre --> Rock
Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk
Command --> I
Song name --> Bad Boys Need Love Too
Artist --> Bahamas (Afie Jurvanen)
Genre --> Folk
Command --> P
My Personal Music Library:
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
The Shade
Metric
Rock
Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk
A song with the name 'Heads Will Roll' is already in the music
library.
No new song entered.
Command --> I
Song name --> Adult Diversion
Artist --> Alvvays
Genre --> Pop
Command --> P
My Personal Music Library:
Adult Diversion
Alvvays
Pop
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
The Shade
Metric
Rock
Command --> S
Enter the name of the song to search for --> Bad Boys Need Love
Too
The song name 'Bad Boys Need Love Too' was found in the music
library.
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Command --> S
Enter the name of the song to search for --> Young Blood
The song name 'Young Blood' was not found in the music
library.
Command --> D
Enter the name of the song to be deleted --> The Shade
Deleting a song with name 'The Shade' from the music library.
Command --> P
My Personal Music Library:
Adult Diversion
Alvvays
Pop
Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk
Heads Will Roll
Yeah Yeah Yeahs
Punk
Command --> Q
Deleting a song with name 'Adult Diversion' from the music
library.
Deleting a song with name 'Bad Boys Need Love Too' from the music
library.
Deleting a song with name 'Heads Will Roll' from the music
library.
The music library is empty.
In: Computer Science
You have 21 cards written from 1 to 21. The number K is inputted from a command window (using input command). First, please shuffle these 21 cards such that the sequence becomes random (using rand command). You need to make a function of New_Cards=shuffle(Orig_Card), where New_Cards is a 1X21 vector that has random sequence of the cards (Ex. New_Cards=[ 14 7 21 6….. 9 1 3 5 8]). When the first even number is greater than K, you should print in the command window saying that ‘You win!’, otherwise ‘You lost!’. K should be set as a global variable in the main cell. Please create a function of Output = game(New_Cards). Output is 1 when the first even number is greater than K, and it is 0 when the first even number is less than K.(Using Matlab)
In: Computer Science
Write a function that takes a string, returns void and has the effect of shifting the vowels of the string to the left. For example, if the input string was “hello class”, then after calling this function the string should contain “holla cless” (note that the first vowel is moved to the location of the last vowel). You can use an auxillary string if you want, but a nicer solution would work “in-place”
In: Computer Science
using C++
24. Using Files—Total and Average
Rainfall
Write a program that reads in from a file a starting month name, an
ending month name,
and then the monthly rainfall for each month during that period. As
it does this, it should
sum the rainfall amounts and then report the total rainfall and
average rainfall for the
period. For example, the output might look like this:
During the months of March–June the total rainfall was 7.32 inches
and the average
monthly rainfall was 1.83 inches.
Data for the program can be found in the Rainfall.txt file.
Hint: After reading in the month names, you will need to read in
rain amounts until
the EOF is reached, and count how many pieces of rain data you read
in.
You can use note pad to create a Rainfall.txt with the following data:
January
May
1.35 2.15 3.03 4.41 5.41
Please note that you must read the first line of the file as starting month and second line as ending month. Please do not hard code the starting and ending month into your program.
test case
During the months of January-May the total
rainfall was 16.35 inches and the average monthly
rainfall was 3.27 inches.
In: Computer Science
I need 40 question for requirements for Library System Management. Put 40 question please that we can get requirements for LSM.
In: Computer Science
Write the IEEE floating point representation (single precision) of 3.75 (Show all your steps to get full credit).
In: Computer Science
Having trouble getting started on this
Overview
As a programmer, you have be asked by a good friend to create a program that will allow them to keep track of their personal expenses. They want to be able to enter their expenses for the month, store them in a file, and then have the ability to retrieve them later. However, your friend only wants certain people to have the ability to view his or her expenses, so they are requesting that you include some sort of login functionality.
Instructions
For this challenge, you will start this application for your friend by concentrating on the login functionality. You will have a standard report in a text file where you will build login functionality to access. Below you will find the step by step instructions on how to develop this application.
what I have so far:
hasAt=False
while (not hasAt):
username= input("what is your username?")
if "@" not in username:
print ("wrong username")
print ("try again loser")
else:
password= input ("what is your password?")
hasAt=True
In: Computer Science
1) Only a single main class is required
2) The main class must contain a static method called "getInputWord" that prompts a user to input a word from the keyboard and returns that word as a String. This method must use "JOptionPane.showInputDialog" to get the input from the user (you can find info about JOptionPane in JavaDocs)
3) The main class must contain a static method called "palindromeCheck" that takes a String as an input argument and returns a boolean indicating whether or not that String is a palindrome. This method must utilize a Stack data structure to determine whether the word is a palindrome. Hint: Use the charAt() method of the String class to access each character of the word
Flow of the Program:
1) Read in a word from the user by calling the "getInputWord" method
2) Check if the word is a palindrome using the "palindromeCheck" method
3) Output the result to the screen using "JOptionPane.showMessageDialog" (you can find info about JOptionPane in JavaDocs)
In: Computer Science
Write a simple matching coefficient and jaccard similarity code in python.
For a example x = 10101 and y = 00101 what is the code to check those similarities in python?
In: Computer Science
SQL Assignment:
Provide a made-up scenario about when a database trigger could be used. There is no need to provide the syntax to create the trigger, as this would differ depending upon the actual design of the database. Only provide the scenario of when a trigger could be used.
In: Computer Science
Java
Math Tutor:
Write a program that displays a menu as shown in the sample run. You can enter 1, 2, 3, or 4 for choosing an addition, subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter 5 to exit the system. Each test generates two random single-digit numbers to form a question for addition, subtraction, multiplication, or division. For a subtraction such as number1 – number2, number1 is greater than or equal to number2. For a division question such as number1 / number2, number2 is not zero.
Here is a sample run: (red indicates a user input)
Main menu 1:
Addition 2:
Subtraction 3:
Multiplication 4:
Division 5:
Exit Enter a choice: 1
What is 1 + 7? 8 Correct
Continue? (y/n) y
Enter a choice: 3
What is 2 * 3? 7
Your answer is wrong.
The correct answer is 6.
Continue? (y/n) n
Good bye!
In: Computer Science
In: Computer Science
What additional features of a MEAN stack applications have to be included in this course and why?
Provide references. 5 points: 3 points for the original post and one point for a meaningful reply.
In: Computer Science