In: Computer Science
each one of the following languages defined over {0,1}, give the transition diagram of a deterministic, single tape Turing Machine.
{03i 1 02i 1 0i | i > 0}
In: Computer Science
Provided that c1, c2 and c3 are of appropriate ranges. Use transform() algorithm so that it copies the larger of the corresponding elements from c1 and c2 to c3. That is, if c1 = {1, 2, 3, 4, 5} and c2 = {5, 4, 3, 2, 1} then c3 should become c3={5, 4, 3, 4, 5}
In: Computer Science
name two differences in Chappe's and mMorse's inventions
In: Computer Science
C++ Lexicographical Sorting
Given a file of unsorted words with mixed case: read the entries in the file and sort those words lexicographically. The program should then prompt the user for an index, and display the word at that index. Since you must store the entire list in an array, you will need to know the length. The "List of 1000 Mixed Case Words" contains 1000 words.
You are guaranteed that the words in the array are unique, so you don't have to worry about the order of, say, "bat" and "Bat."
For example, if the array contains ten words and the contents are
cat Rat bat Mat SAT Vat Hat pat TAT eat
after sorting, the word at index 6 is Rat
You are encouraged to use this data to test your program.
In: Computer Science
This is a c++ code. Write a series of assignment statements (complete executable code) that find the first three positions of the string “and” in a string variable sentence. The positions should be stored in int variables called first, second and third. You may declare additional variables if necessary. The contents of sentence should remain unchanged. The sentence can be completely random.
Im having a large problem with this. It's a simple c++ code, but im unable to get it. Thank you.
In: Computer Science
Please write JavaScript and HTML code for the following problems
Problem 1 - Array Usage
Ask the user to enter positive numeric values. Store each value in an array. Stop reading values when the user enters -1. After all values have been entered, calculate the sum and the average of the values in the array (if you do not know what a sum or average is, or how to calculate them, it is your responsibility to look up this information). Print out the values entered by the user, the sum of those values, and the average value.
You must create one function that calculates the sum of the values in the array and one function that calculates the average of the values in the array.
Problem 2 - Circles
For this problem, you will create a simple HTML page that allows the user to draw circles by clicking inside of a canvas element.
The HTML page shall contain a title, a header, two text fields, and a canvas. The title shall include your name. The header shall contain the text "Problem 2". The first text field shall have a label indicating that the field controls the number of circles that will be drawn. The second text field shall have a label indicating that the field controls the radius of the circles that will be drawn. The canvas shall have a height of 400 pixels and a width of 600 pixels.
The HTML page shall also contain a script that uses an event listener to draw circles whenever the user clicks inside of the canvas element with their mouse. The number of circles to draw, and the radius of the circles, shall be obtained from the text fields. Each circle shall be colored with an alpha value of 0.1. The canvas shall be cleared before any circle is drawn. The x and y position of each circle shall be randomly determined. You can use the following code to assign a random value to x and y:
let x = Math.floor(Math.random() * (width - 2 * r)) + r; let y = Math.floor(Math.random() * (height - 2 * r)) + r;
In: Computer Science
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