code in C
Step 1
For example: chrLetter = fgetc( pfilInput );
Step 2
typedef struct
{
long lngRecordID;
char strFirstName[ 50 ];
char strMiddleName[ 50 ];
char strLastName[ 50 ];
char strStreet[ 100 ];
char strCity[ 50 ];
char strState[ 50 ];
char strZipCode[ 50 ];
} udtAddressType;
Step 3
Step 4
------------------------------------------------------------
Customer #1
First Name: Luke
Middle Name:
Last Name: Skywalker
Address: 123 Elm Street
City: Corusant
State: Ohio
Zip Code: 45202
------------------------------------------------------------
Customer #2
…
Extra Credit
Extra Extra Credit
In: Computer Science
C++ language:
Class Song
The class will have the following private attributes:
It will also have the following public member functions:
Playing *Title* by *Artist* *playtime* seconds
Implement the missing functions using the template provided.
Class MusicLibrary
MusicLibrary has the following private attributes
Note that mySongs is a pointer that will be used to initialize a dynamic array of songs. You need to handle this dynamic array correctly (e.g. shallow copies, memory deallocation etc.)
playList is a dynamic array of pointers to Songs in the mySongs array.
The class also includes the following public member functions:
This class is partially implemented. Complete the following:
If the Playlist is full, print the following error message
Could not add Song to PlayList. PlayList is full
If the integer denoting the position of a song in the MusicLibrary is invalid, print the following error message
Invalid song
A sample main file has been provided showing the utilization of the functions, as well as a sample input file.
IMPORTANT
main.cpp:
#include <iostream>
#include <string>
#include "Song.h"
#include "MusicLibrary.h"
using namespace std;
int main()
{
string filename;
int numsongs;
cout << "Enter number of Songs " << endl;
cin >> numsongs;
cout << "Enter filename with information about the songs" << endl;
cin >> filename;
MusicLibrary mylibrary(numsongs);
mylibrary.readSongsFromFile(filename);
mylibrary.playRandom();
for (int i = numsongs-1; i >= 0; i--) {
mylibrary.addSongToPlayList(i);
}
mylibrary.playPlaylist();
return 0;
}
musicLibrary.cpp:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "MusicLibrary.h"
MusicLibrary::MusicLibrary(int maxsongs)
{
// implement constructor
}
MusicLibrary::MusicLibrary(MusicLibrary& other)
{
// implement copy constructor
}
MusicLibrary::~MusicLibrary()
{
delete[] mySongs;
delete[] playList;
}
int MusicLibrary::getnumSongs()
{
return numSongs;
}
int MusicLibrary::getmaxSongs()
{
return maxSongs;
}
int MusicLibrary::getnumSongsPlayList()
{
return numSongsPlayList;
}
bool MusicLibrary::addSong(string title, string artist, string album, int year, int time)
{
if (numSongs == maxSongs) {
cout << "Could not add song to library. Library is full" << endl;
return false;
}
mySongs[numSongs].setTitle(title);
mySongs[numSongs].setArtist(artist);
mySongs[numSongs].setAlbum(album);
mySongs[numSongs].setYear(year);
mySongs[numSongs].setPlayTime(time);
numSongs++;
return true;
}
bool MusicLibrary::addSong(Song& song)
{
if (numSongs == maxSongs) {
cout << "Could not add Ssong to library. Library is full" << endl;
return false;
}
mySongs[numSongs] = song;
numSongs++;
return true;
}
void MusicLibrary::readSongsFromFile(string filename)
{
ifstream input;
input.open(filename);
bool cont = true;
if (input.is_open()) {
string line;
while ( getline(input, line) && cont ) {
string title, artist, album;
string s_year, s_time;
int year;
int time;
istringstream inSS(line);
getline(inSS, title, ',');
getline(inSS, artist, ',');
getline(inSS, album, ',');
getline(inSS, s_year, ',');
getline(inSS, s_time);
year = stoi(s_year);
time = stoi(s_time);
cont = addSong(title, artist, album, year, time);
};
}
else {
cout << "could not open file " << filename << endl;
}
}
void MusicLibrary::playRandom()
{
// implement this method
}
bool MusicLibrary::addSongToPlayList(int pos)
{
// implement this method
}
void MusicLibrary::playPlaylist()
{
// implement this method
}
musicLibrary.h:
#pragma once
#include <string>
#include "Song.h"
using namespace std;
class MusicLibrary
{
private:
int maxSongs;
int numSongs; // number of Songs in library
Song* mySongs; // dynamic array storing all Songs
int numSongsPlayList; // number of Songs in Playlist
Song** playList; // dynamic array of pointers to Songs
public:
MusicLibrary(int maxsongs);
MusicLibrary(MusicLibrary& other);
~MusicLibrary();
int getnumSongs();
int getmaxSongs();
int getnumSongsPlayList();
bool addSong(string title, string artist, string album, int year, int time);
bool addSong(Song& song);
void readSongsFromFile(string filename);
bool addSongToPlayList(int pos);
void playRandom();
void playPlaylist();
};
song.cpp:
#include <iostream>
#include "Song.h"
void Song::Play()
{
cout << "Playing "<< Title << " by " << Artist << " " << PlayTime << " seconds" << endl;
}
// Add code for constructors, accessors, mutators, and == operator.
song.h:
#pragma once
#include <string>
using namespace std;
class Song {
private:
string Title;
string Artist;
string Album;
int Year;
int PlayTime;
public:
// Add declaration for constructors, accessors and mutators
// Add declaration for overloading the == operator
void Play();
};
songs.txt:
Zoo Station, U2, Achtung Baby, 1991, 203
Youngblood, 5 Seconds of Summer, Youngblood, 2018, 311
Money for Nothing, Dire Straits, Brothers in Arms, 1986, 501
Summer of 69, Bryan Adams, Reckless, 1984, 178
Livin on a Prayer, Bon Jovi, Slippery when Wet, 1986, 241
In: Computer Science
In: Computer Science
PYTHON QUESTION
Create a subclass of the Dog class named anything appropriate (e.g. Bulldog, Chihuahua, German Shepherd, etc). This subclass should consist of the following:
1. It should inherit the __init__ method from the Dog class, but add one new attribute at instantiation.
2. It should add two new methods that were not in our Dog class
3. It should overwrite one of the methods that existed in the Dog class.
-------
I'm not entirely sure where I should add this information to my dog class, nor how I should go about overwriting one of the methods.
-------
class Dog:
def __init__(self,name,age):
self.name = name
self.age = age
def description(self):
return self.name + ' is' + str(self.age) + ' years old.'
def speak(self):
return self.name + ' barks!'
def run(self):
return self.name + ' is running!'
def fetch(self, toy):
print(self.run())
print(self.name + ' fetched the ' + toy)
print(self.name + ' is bringing it back!')
def wags_tail(self):
return self.name + ' is so happy!'
def isolder(self, dog2):
if self.age > dog2.age:
return True
else:
return False
dog1 = Dog('Hurc', 2)
dog2 = Dog('Sammy', 5)
print(dog1.description())
print(dog1.speak())
print(dog1.run())
dog1.fetch('ball')
print(dog1.wags_tail())
print(dog1.isolder(dog2))In: Computer Science
Do this in python with code that I can copy and run
Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods:
Assume that the station and volume settings range from 1 to 10.
The radio station is X and the volume level is Y. Where X and Y are the values of variables station and volume. If the radio is off, the message is: The radio is off.
Now design and implement a test program to create a default radio object and test all class methods on the object in random order. Print the object after each method call and use meaningful label for each method call as shown in the following sample run.
Sample run:
Turn radio on:
The radio station is 1 and the volume level is 1.
Turn volume up by 3:
The radio station is 1 and the volume level is 4.
Move station up by 5:
The radio station is 6 and the volume level is 4.
Turn volume down by 1:
The radio station is 6 and the volume level is 3.
Move station up by 3:
The radio station is 9 and the volume level is 3.
Turn radio off.
The radio is off.
Turn volume up by 2: The radio is off.
Turn station down by 2: The radio is off.
In: Computer Science
1) As a software engineer what are your legal and ethics responsibilities when you work for medical and military application?
2) What are the two levels of system design? Describe their corresponding main purpose briefly
3) What is double blind test? How to use this test to objectively compare the goodness of two software system, (e.g... google vs Bing.)
4) Define and Describe the main pros and cons of three software cost estimation methods
Compare the following concepts ( state the respective definitions and the difference)
- understandability vs user-friendliness
-software debugging vs. software testing
-black-box testing vs white-box testing
-software re-engineering vs reverse software engineering
In: Computer Science
Describe how you would adapt the RGB color model in WebGL to allow you to work with a subtractive color model.
In: Computer Science
Cyber Security class
1. Your task is to compute a session key KAB in Diffie-Hellman Key Exchange (DHKC) with Elliptic Curves. Your private key is a = 6. You receive Bob’s public key B = (5,9). The elliptic curve being used is defined by y2 ≡ x3+x+6 mod 11.
2. In RSA Digital Signature, Suppose Bob wants to send a signed message (x = 4) to Alice. The first steps are exactly the same as it is done for an RSA encryption: Bob computes his RSA parameters and sends the public key to Alice. We know p = 3, q =11, and bob choose e=3. (Hint: We learn RSA algorithm and key generation in Week 7)
(a) What is the public key pair Bob sends to Alice?
(b) What is the value of signature s?
(c) What is the value of verkpubA(x,s)? Show all intermediate steps clearly.
Prove in RSA digital signature, verkpubA(x,s) = x
In: Computer Science
public class ValidBST {
class BSTTest<Key extends Comparable<Key>, Value> {
private Node root; // root of BST
private class Node {
private Key key; // sorted by key
private Value val; // associated data
private Node left, right; // left and right subtrees
public Node(Key key, Value val) {
this.key = key;
this.val = val;
}
}
}
public boolean isValidBST(BSTTest bst) {
return false;
}
public static void main(String[] args) {
}
}
In: Computer Science
Write an AWK program that takes as input salary_file (Imaginary File). The
salary_file consists around 150 records, each record having three fields: name, salary per hour,
and hours worked -- fields 1, 2, and 3, respectively. Save your AWK program in a file. Name the
file according to our standard convention but with .awk extension, hence name it
As5_yourName_p2.awk. Do not forget to have comments inside of your AWK file.
Your AWK program should have all three segments: BEGIN, main (pattern/action), and END
blocks
1. In the BEGIN segment
1. print your name
2. introduce/initiate variables that you are going to use in parts 2. and 3. of this
Problem
2. In the main block/segment, print
1. only names and salaries of employees that earned more than $700.00
2. names of all employees whose names start with capital A, G or W
3. In the END segment, print
1. total number of employees
2. cumulative hours worked by all employees
3. name of the employee that earned the most
4. name of the file that AWK (this program) is processing
In: Computer Science
C++
I have to create printArray, but I have the error " error C2065: 'ar': undeclared identifier". Just need a little help.
#include
#include
#include
using namespace std;
void fillArray(int a[], int size);
void printArray(int a[], int size);
int main()
{
int ar[10];
fillArray(ar, 10);
printArray(ar, 10);
return 0;
}
void fillArray(int a[], int size)
{
for(int i = 0; i < 10; i++)
a[i] = rand() % 10 + 1;
}
void printArray(int a[], int size)
{
for (int i = 0; i < 10; i++)
cout << ar[i];
}
In: Computer Science
There are wide applications of the searching algorithm, where given a list of objects, to find whether the search target is in the list.
The intuitive solution is that we walk through the list until the search target is found or the end of the list is reached. The solution is called Linear Search.
For general purpose, let us use ListADT and define a static generic linear search method as follows:
public static <T extends Comparable<T>> int search(ListADT<T> array, T targetValue) throws EmptyCollectionException;
Please implement the linear search method, which walks through the given list and search for the targetValue until the targetValue is found or the end of the list is reached. If the targetValue is found, the method returns the index of the targetValue in the list or else it returns -1.
public static <T extends Comparable<T>> int search(ListADT<T> array, T targetValue) throws EmptyCollectionException {
}
In the hands-out or your sketchbook, please write down your code and take a snapshot and submit it.
Additionally, discuss and answer the following question:
what are the worst and average case running times for serial search?
In: Computer Science
Write a C++ program to check whether a number is prime or not. A prime number is a positive integer that has exactly two positive integer factors, 1 and itself. Eg: 2, 3, 5, 7, 11, 13, 17, ...
Sample Output:
Input a number to check prime or not: 13 The entered number is a
prime number.
Input a number to check prime or not: 28 The entered number is not a prime number.
Enhance the program to list all factors if the number is not
prime Input a number to check prime or not: 28
The entered number is not a prime number.
Factors: 1, 2, 4, 7, 14, and 28
In: Computer Science
C++ AVL tree
My AVL tree function
void inorder(AVLNode* t)
{
if (t == NULL)
return;
inorder(t->left);
cout << t->data.cancer_rate << " ";
inorder(t->right);
}
void inorder()
{
inorder(root);
}
Will Print my cancer city rate Inorder
example)...you can use any input as long it is a float
3.1
5.8
19.8
22.2
33.3
44.4
[Qustion]
How do I make a function that only prints the last one of my AVLTree ,in this case a function that only prints 44.4
And how do I make a function that only prints the first one of my AVLTree ,in this case a function that only prints 3.1
I think this can be accomplished by editing the inorder function
In: Computer Science
In Java
Write a GUI that will let the user sample borders. Include a menu named Borders that offers three options—beveled border, etched border, and line border—as submenus with the following options:
• Beveled-border submenu options: raised or lowered.
• Etched-border submenu options: raised or lowered.
• Line-border submenu options: small, medium, or large. Each of these options should be a submenu with three color options: black, red, and blue. Put the borders around a label containing text that describes the border, such as Raised Border, Lowered Etched Border, and so forth. Fix the highlight and shadow colors for the etched-border options to whatever colors you like, and make the small line border 5 pixels wide, the medium one 10 pixels wide, and the large one 20 pixels wide.
In: Computer Science