Project 8-2: Person Manager
Create an application that lets you enter a new customer or a new employee.
Create a class named Person with these constructors and methods:
public Person(String first, String last)
public String getFirstName()
public void setFirstName(String first)
public String getLastName()
public void setLastName()
The Person class should override the toString() method so it returns the first name and last name in this format:
Name: Frank Jones
Create a class named Customer that inherits the Person class and contains these constructors and methods:
public Customer(String first, String last, String number)
public String getCustomerNumber()
public void setCustomerNumber(String number)
The Customer class should override the toString() method so it returns the value returned by the toString() method of the Person class appended with the customer number, like this:
Name: Frank
Jones
Customer Number: J54128
Create a class named Employee that inherits the Person class and contains these constructors and methods:
public Employee(String first, String last, String ssn)
public String getSsn()
public void setSsn(String ssn)
The getSsn() method should return a masked version of the social security number that only reveals the last four numbers.
The Employee class should override the toString() method so it returns the value returned by the toString() method of the Person class appended with the social security number, like this:
Name: Frank
Jones
SSN: xxx-xx-1111
In: Computer Science
Using C# .NET Core console application that contains the following:
1. Use this variable:
string baconIpsum = "Bacon ipsum dolor amet picanha tri-tip pig pork bacon turducken. Leberkas short ribs prosciutto pork belly ribeye capicola alcatra short loin ham hock rump jowl pig flank beef. Venison tenderloin tail, cupim salami pastrami meatball jerky filet mignon. Salami jerky short loin, chicken pig pork tenderloin rump meatball sausage pancetta sirloin. Drumstick tenderloin ham pork belly cupim, ground round prosciutto jerky ball tip kielbasa tongue andouille picanha alcatra. Ham ribeye t-bone, boudin buffalo pork chop beef tri-tip. Bacon filet mignon frankfurter kevin, pork chop burgdoggen bacon bacon ham hock beef ribs bresaola turkey meatball corned beef.";
2. Use string manipulation, output of a count of how many sentences are in your string variable
3. Use a loop to iterate through each sentence
4. If the string "bacon" is found in the sentence, output a happy sentence, otherwise, output a sad sentence to the console
5. Output how many times bacon is in baconIpsum and tell if that is enough bacon for you
In: Computer Science
For this problem you should describe the algorithm using a flowchart and then write Python code to implement the algorithm. You are to create a Python program file for your code. Include in your HW document a photo of your flowchart and a screenshot of your program file and the output in IDLE that results when you run the program. The algorithm: Ask the user to input their annual salary and then calculate and print the weekly salary (annual/52). I just want the flowchart
In: Computer Science
Draw the ERD in Chen notation corresponding to the following spec:
In: Computer Science
2.26 Homework 2-3 Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = Unknown node type: sup πrUnknown node type: sup sphereArea = Unknown node type: sup 4πrUnknown node type: sup sphereVolume = Unknown node type: sup 43πrUnknown node type: sup You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area = circleArea Sphere Area = sphereArea Sphere Volume = sphereVolume Please make sure to end each line of output with a newline. Please note that your class should be named CircleSphere.
In: Computer Science
Refer to the MediCo case study to answer the following questions
For the To-Be or target architecture of the MediCo change
Question 4
Describe the Application Structure viewpoint in terms of
Stakeholders, Concerns, Purpose and Scope. Which specific core
elements will be included in this viewpoint? (10)
Question 5
Describe the Technology usage viewpoint in terms of Stakeholders,
Concerns, Purpose and Scope. Which specific core elements will be
included in this viewpoint? (10)
Question 6
Describe the Business Process Cooperation viewpoint in terms of
Stakeholders, Concerns, Purpose and Scope. Which specific core
elements will be included in this viewpoint? (10)
In: Computer Science
Written in MIPS assembly language
If given an array which is sorted in ascending order, as well as its length and a target value. You are asked to find the index of this target value in the array using binary search algorithm. Here is an example: array 1, 4, 6, 8, 10, 12 length 6 target 8 2 In this case, the returned result should be assigned to be 3, as array[3] is equal to target. (Note: The target will exist in this array and will not be the first or last element, so there is no need to consider corner cases.) This task should be easy for high-level programming languages, such as C++, Java or Python. However, in this lab, you are asked to implement it in assembly language. Writing programs in a low-level language helps you learn how high-level operations are handled by CPUs.. The size of the sorted array can be fairly large, up to 2048 elements. Please avoid storing temporary variables in data memory (store them in registers instead). In order to simply your future work you the operators and operands that you are allowed to used in your code are limited to those given below: lui, lw, sw, add, sub, addi, srl, sll, and, or, andi, ori, xor, nor, slt, beq, bne, j, t0-t7, s0-s7, zero. Use the template "lab1-template.s" on git and fill the blank starting from "main:" with your code. (Please DO NOT change anything else.) SPIM automatically makes the program counter pc point to the main function when initialized. Your answer should be stored in the address of result, which is 0x10010008 in the template. Check you code with the provided correct pairs of input and output before submission.
In: Computer Science
Hi!
I am trying to compare 2 files, and figure out which lines from infile2 are also in infile1, and output the line index, from infile2, of common lines. I would also want to see which lines (actual string line) are common.
Below is my c++ program, and I am not sure what I am doing wrong. Can someone tell me what I am doing wrong and how it can be fixed?
_________________________________________________________main.cpp
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;
int main(int argc, char *argv[]){
string myString1, myString2;
vector<string> string1, string2;
int i = 0;
int y = 0;
ifstream infile1("LeftShift2.txt");
ifstream infile2("LeftShift3.txt");
if(infile1.is_open() && infile2.is_open())
{
while(!infile1.eof() && !infile2.eof())
{
getline(infile1, myString1);
string1.push_back(myString1);
getline(infile2, myString2);
string2.push_back(myString2);
if(string1.at(i) != string2.at(y))
{
y++;
}
else if(string1.at(i) == string2.at(y))
{
i++;
}
}
cout<<"common line is at: " << y << endl;
cout<<"The common lines are: "<< string2.at(y) << endl;
}
infile1.close();
infile2.close();
return 0;
}
__________________________________________LeftShift2.txt
Adios amiga mia
Bella ciao
Si le monde etait aussi petit
On ne serait pas aussi grandiose
Pays du lait et du miel
Alors, on danse?!
-------------------------------------------------------------LeftShift3.txt
Pays du froid et des montagnes
Burundi
Pays du lait et du miel
Adios amiga mia
-------------------------------------------------------------Output (assume count line start at 0)
common line is at: 2
The common lines are: Pays du lait et du miel
common line is at: 3
The common lines are: Adios amiga mia
In: Computer Science
I have the following code
#include <stdio.h> #include<string.h> #define BUFLEN 128 typedef struct { int numPhrases; }SyncInfo; char buffer[BUFLEN] ; char *phrases[] = {"educated", "educated cat", "educated lion", "serious person" , "serious panda","curious student","curious art student", "obnoxious web developer"}; char localBuffer[BUFLEN]; int allVowelsPresent; void *checker(void *param) { int a=0, e=0, i=0, o = 0, u= 0 ; int* n = (int*)param; // typecasting a void* to int* //printf("%d\n",*n); for (int q=0; q< (*n); ++q) { // dereferencing to get the value in int* strcpy(localBuffer, buffer); int length=strlen(localBuffer); // strlen is used to determine the length of localBuffer for(int j=0 ; j<length;j++) // iterating over the whole length of localBuffer and checking if vowel present { if(localBuffer[j]=='a') a=1; else if(localBuffer[j]=='e') e=1; else if(localBuffer[j]=='i') i=1; else if(localBuffer[j]=='o') o=1; else if(localBuffer[j]=='u') u=1; } if(a&&e&&i&&o&&u) // if all are present ie none of the value of a, e, i, o ,u is 0 then all vowels are present allVowelsPresent = 1 ; else allVowelsPresent = 0 ; } } int main() { SyncInfo syncinfo; syncinfo.numPhrases = 8; SyncInfo* p = &syncinfo; // defining pointer of type SyncInfo pointing to syncinfo void* param = &p->numPhrases; // a void pointer as we have to pass void* in checker function for (int i=0; i<syncinfo.numPhrases; ++i) { strcpy(buffer, phrases[i]); checker(param); // main() calling the checker function printf("result of checking ’%s’: %d\n", phrases[i], allVowelsPresent) ; } }
In this code I didn't create a separate thread to do the checking , may someone implement and modify this. Also My checker function should have Syncinfo *s =(Syncinfo*) param please add that modification as well . The code works perfectly fine , just need to make some modification .
In: Computer Science
How does a WAN differ from a LAN and what must be taken into consideration in terms of communications media? Support your rationale.
In: Computer Science
I had a question like this but I forgot to add more and I could not edit it. So here is the new one with more explanation.
I am confused with my Python assignment. I have to write a specification for an email address, Then change the test strings in the code to one string with a valid email address and the other without a valid email address.
This my example/code that it is supposed to be used as a guide:
import re
def text_match(text):
patterns = '^\w+'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
print(text_match("My teacher’s email is [email protected]"))
print(text_match("My teacher has no email address"))
For some reason chegg does not want to indent my lines. the if and else statement should be properly indented in the example
In: Computer Science
import java.util.ArrayList;
/*
Lab-08: BinarySearchTree Implementation
Rules:
1. Allow Tester to iterate
through all nodes using the in-order traversal as the
default.
This
means, in Tester the following code should work for an instance of
this class
called bst
that is storing Student objects for the data:
BinarySearchTree_Lab08<String> bst = new
BinarySearchTree_Lab08<String>();
bst.add("Man");
bst.add("Soda"); bst.add("Flag");
bst.add("Home");
bst.add("Today"); bst.add("Jack");
for(String s : bst)
System.out.println(s);
2. You can not
use a size variable to keep track of the number of nodes
*/
/**
* Lab-08: BinarySearchTree Implementation
*
* @author
*
*/
public class BinarySearchTree_Lab08<T> {
//======================================================================================
Properties
private Node root;
//======================================================================================
Constructors
public BinarySearchTree_Lab08() {
}
// Constructor that takes an array of items and
populates the tree
public BinarySearchTree_Lab08(T[] items) {
}
//======================================================================================
Methods
public void add(T data) { // Implement
recursively and do NOT allow duplicates
}
// Returns the traversal of this tree as an
array
public ArrayList<T> preOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
preOrder_Traversal(root,
data);
return data;
}
private void preOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> inOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
inOrder_Traversal(root,
data);
return data;
}
private void inOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> postOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
postOrder_Traversal(root,
data);
return data;
}
private void postOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> breadthFirst_Traversal()
{
return null;
}
// Since this is a binary SEARCH tree, you should
write
// an efficient solution to this that takes advantage
of the order
// of the nodes in a BST. Your algorithm should be, on
average,
// O(h) where h is the height of the BST.
public boolean contains(T data) {
return false;
}
// returns the smallest value in the tree
// or throws an IllegalStateException() if the
// tree is empty. Write the recursive version
public T min() { return min(root); }
// this method is done for you.
private T min(Node n) { // Write this
method.
return null;
}
// returns the largest value in the tree
// or throws an IllegalStateException() if the
// tree is empty. Write the recursive version
public T max() { return max(root); }
// this method is done for you.
private T max(Node n) { // Write this
method.
return null;
}
// Returns whether the tree is empty
public boolean isEmpty() {
return false;
}
// returns the height of this BST. If a BST is
empty, then
// consider its height to be -1.
public int getHeight() {
return -1;
}
// returns the largest value of all the leaves
// If the tree is empty, throw an
IllegalStateException()
// Note, this is different than max as this is the
max
// of all leaf nodes
public T maxLeaf() {
return null;
}
// counts the number of nodes in this BST
public int nodeCount() {
return -1;
}
// returns the "level" of the value in a
tree.
// the root is considered level 0
// the children of the root are level 1
// the children of the children of the root are level
2
// and so on. If a value does not appear in the tree,
return -1
// 15
// / \
// 10 28
// \ \
// 12 40
// /
// 30
// In the tree above:
// getLevel(15) would return 0
// getLevel(10) would return 1
// getLevel(30) would return 3
// getLevel(8) would return -1
public int getLevel(T n) {
return -1;
}
// A tree is height-balanced if at each node, the
heights
// of the node's two subtrees differs by no more than
1.
// Special note about null subtrees:
// 10
// \
// 20
// Notice in this example that 10's left subtree is
null,
// and its right subtree has height 0. We would
consider this
// to be a balanced tree. If the tree is empty, return
true;
public boolean isBalanced() {
return false;
}
//======================================================================================
Inner Node Class
private class Node {
private T data;
private Node left, right;
private Node(T data) {
this.data =
data;
left = right =
null;
}
}
}
In: Computer Science
Python
Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following
For example, consider the following code fragment:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(key, data_list, size)
The data_list contains a list of tuple objects. Each tuple consists of the time-period value and the packet-size. You should summarize this list and create a frequency list, a sum of the packet-size list and an average of the packet-size list. There are a lot of data for each time-period value. We calculate the total number of bytes that the source host sent for each 10-second interval. For example, the above data_list will be divided into 3 groups, such as (0-9 second), (10-19 second) and (20-29 second)
Therefore, the IP_address object should contain:
This will give
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_ip_address()) |
192.168.0.24 |
And
For example, consider the following code fragment:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(key, data_list, size)
The data_list contains a list of tuple objects.
Therefore, the IP_address object should contain:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 10], [1, 10], [2, 1]] |
|
ip_key = '192.168.0.24' data_list = [(0, 84), (1, 84), (2, 84), (3, 84), (4, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 5], [1, 0], [2, 0]] |
|
ip_key = '192.168.0.2' data_list = [(33, 60), (34, 64), (34, 1500), (34, 712), (35, 52), (35, 60), (36, 52), (36, 287), (37, 52), (37, 52), (37, 52), (39, 60), (40, 643), (40, 52)] size = 5 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 0], [1, 0], [2, 0], [3, 12], [4, 2]] |
In: Computer Science
In Java, What is gained by having a Tail reference/pointer in your Linked List?
A. The tail is superfluous and offers no benefits
B. The tail allows us to speed up a few operations and gives us an end point to look for
C.Since we have head and tail we can now do a Binary Search on the list
D. It only makes deleting from the end of the list faster
In: Computer Science
Write a C function hwkOneA, that takes a long int x as well as two integers n and m as arguments, and returns a long int. Here is the function declaration: long int hwkOneA (long int x, int n, int m); The function should swap nibble n and m of a long int x (64-bit integer). A nibble is a four-bit aggregation. For this problem, the index of the most significant nibble is 0, and the index of the least significant nibble is 15 (so 0 , =), loops, switches, function calls, macros, conditionals (if or ?:) You are allowed to use all bit level and logic operations, left and right shifts, addition and subtraction, equality and inequality tests, integer constants (<=255), INT_MIN and INT_MAX, and casting between data types. (20 points).
In: Computer Science