Questions
File has a format Name and number, the number represents power. The name and the (integer)...

File has a format Name and number, the number represents power. The name and the (integer) power are separated by some amount of space. Importantly, any line that begins with a hash '#' are comments and they need to be ingored. Write a program that reads from that file, and prints out only the name of the hero with the strongest power. That name should be capitalized (not uppercase, but capitalized, as in 'Galadriel')

Here is the heroes.txt

# DC heroes
# format: "name" "power"
# 57
# 83
hal 12
batman 48
grayson 14
cyclone 24
superman 38
luthor 15
joker 18
drake 33
wayne 42
rayner 18
# below heroes are additional heroes
arrow 22
kord 48
batwoman 37
supergirl 49
stargirl 24
darkseid 41
gardner 28
pennyworth 27
west 12
aquaman 47
kallor 45
arisia 36

What i have so far:

fn = open('heroes.txt')
count = 0

for z in fn:
line = z.strip()
  
if not '#' in line:
print(line.capitalize())
continue
po1 = line.find()
print(po1)
  
fn.close
  

In: Computer Science

Consider a 10Mbps Ethernet network consisting of 20 nodes interconnected by a bus topology with a...

Consider a 10Mbps Ethernet network consisting of 20 nodes interconnected by a bus topology with a single bridge placed in the approximate center of the network resulting in an equal umber of nodes on each side of the bridge.

  1. Briefly explain why collisions can/cannot occur.
  1. If two pairs of nodes attempted to communicate at the same time, discuss the throughput they can achieve.

In: Computer Science

Given a Syntax Directed Translation as follows. Production Semantic Rules L → E n L.val =...

Given a Syntax Directed Translation as follows.

Production

Semantic Rules

L → E n

L.val = E.val

E → E1 + T

E.val = E1 .val + T.val

E → T

E.val =T.val

T → T1 * F

T.val = T1.val x F.val

T → F

T.val = F.val   

F → ( E )        

F.val = E.val

F → digit

F.val = digit.lexval

Question

Create an annotated parse tree for the following statements

  1. a. (3+4) * (5+6)n
  2. b. 1*2*3*(4+5)n

In: Computer Science

Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D

Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.

Shape2D class

For this class, include just an abstract method name get2DArea() that returns a double.

Rectangle2D class

Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.

Rectangle2D class

Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.

Shape2DDriver class

Have this class provide a method named displayName() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.

In: Computer Science

Two computers have 7-stage fetch-execute cycles where branches are determined in stage 4. One computer is...

Two computers have 7-stage fetch-execute cycles where branches are determined in stage 4. One computer is not pipelined, and the other is pipelined. Assuming that tp = 1, answer the following questions when running a program with 50,000 instructions where 1,000 of the instructions are conditional branches and each branch, if taken, skips over 10 instructions.a.How much faster is the pipelined machine over the non-pipelined machine assuming that no branches are taken.b.How much faster is the pipelined machine over the non-pipelined machine assuming that all branches are taken.c.Bonus question: How many branches would the program have to have assuming every branch is taken (and every branch skips over 10 instructions) for the non-pipelined machine to execute the program in the same time as the pipelined machine?

In: Computer Science

There are 4 processes with different arrival time and service time. Process Arrival Service A 0...

There are 4 processes with different arrival time and service time.

Process

Arrival

Service

A

0

10

B

3

4

C

5

6

D

7

2


a. Use FCFS, RR(4), SPN, SRT, and HRRN to schedule them. Calculate the waiting time and turnaround time for each process and the average turnaround time for each algorithm.

b. Compare all the 5 algorithms. Considering the overhead time for each scheduling takes 1 time unit, which is the best? If the overhead takes 4 time units, which is the best?

In: Computer Science

Use R programming Language Q1. (a)Write a function called lowerTrim that takes 2 arguments: x and...

Use R programming Language

Q1.

(a)Write a function called lowerTrim that takes 2 arguments: x and trimBelow. This function takes the average of those values in x that are greater than the trimBelow. Make x a required argument and supply a default value for trimBelow of negative infinity.

First create some variable to be used for testing later.

x = 1:5
y = letters
z = list(a = 1:5, b = 1:10)

Now test your function with the following

lowerTrim(x)
lowerTrim(-10:5, trimBelow = 0)
lowerTrim(-10:5, -2)
lowerTrim(x = -10:5, trimBelow = Inf)

The return values should be: 3, 3, 2, and NaN, respectively

(b). Extend your function so that it takes a third parameter, which allows the caller to use a function other than mean() when calculating the lowerTrim. Call this argument sumFunc and give it a default value so that it operates like the original lowerTrim function. Call this revised function lowerTrim2

Check your function with the following calls:

lowerTrim2(-10:20, trimBelow = -5, median)
lowerTrim2(-10:20, trimBelow = 0, sumFunc = summary)

The return values should be 8 and the summary values of 1, 5.75 10.5, 10.5, 15.2, and 20.

(c) Modify your function to take in any argument through the ... argument and pass these arguments. Call this new function lowerTrim3.

And test your code with

lowerTrim3(x, sumFunc = sd)
lowerTrim3(-10:20, trimBelow = 0, sumFunc = quantile,
           probs = 0.99)
lowerTrim3(-10:20, trimBelow = 0, trim = 0.1)

The results should be 1.58, 19.8, and 10.5.

In: Computer Science

Java program that display ATM booth line by using data sturcture Queue.

Java program that display ATM booth line by using data sturcture Queue.

In: Computer Science

For Problems 1–4, using the STORES Database, formulate SQL queries, Hand in a listing of each...

For Problems 1–4, using the STORES Database, formulate SQL queries, Hand in a listing of each query and its output.

1. (10 Points) For each customer, list each stock item ordered, the manufacturer, the quantity ordered, and the total price paid. Include the following columns in the order given below:

From Customer Table:              Company

From Stock Table:                      Description

From the Manufact Table:        Manu_Name

From the Items Table:                                Quantity, Total Price

Order the output by Company and Description.

2. (10 Points) List all orders with a shipping date between December 25, 1999 and January 5, 2000. List the Order Number, Order Date, Customer company name, and Shipping Date. Order by Customer Company Name and Order Number.

3. (10 Points) Count the number of customers who do not have any orders placed.

4. (10 Points) List all customers who are ordering equipment whose description begins with ‘tennis’ or ‘volleyball’. List the Customer number, Stock number, and Description. Do not repeat any rows.

5. (15 Points) Use the following SQL CREATE commands to CREATE the following tables in your

User ID:

                                CREATE TABLE Professor

                                (Prof_ID                NUMBER(3) Constraint pk_Professor Primary Key,

                                Prof_Lname         VARCHAR2(15)                 NOT NULL,

                                Prof_Hiredate      DATE,

                                Prof_Sal                NUMBER(8,2),

                                Prof_Dept             CHAR(6)

                                );

                                CREATE TABLE Student

                                (Stu_ID                  NUMBER(4) Constraint pk_Student Primary Key,

                                Stu_Lname           VARCHAR2(15)                 NOT NULL,

                                Stu_Major            CHAR(6),

Stu_CredHrs         NUMBER(4),

                                Stu_GradePts       NUMBER(5),

                                Prof_ID                 NUMBER(3),

                                CONSTRAINT fk_Student_Prof_ID FOREIGN KEY(Prof_ID)

                                                REFERENCES Professor

                                );

Hand in: Print out of the Create commands, the system response and a DESCRIBE of the tables.

6. (15 Points) Insert the following data into the tables created above using SQL INSERT commands.

Professor Table:

Prof_ID

Prof_Lname

Prof_Hiredate

Prof_Sal

Prof_Dept

123

Hilbert

20-MAY-1992

58000.00

MATH

243

Newell

15-JUL-1997

65500.00

CMPSCI

389

Lessing

04-APR-1988

40250.00

ENG

Student Table:

Stu_ID

Stu_Lname

Stu_Major

Stu_CredHrs

Stu_GradePts

Prof_ID

2001

Parker

CMPSCI

52

160

243

2166

Smith

ENG

30

75

389

3200

Garcia

MATH

62

248

123

4520

Smith

CMPSCI

45

157

NULL

In: Computer Science

Develop a simple point-to-point Message communication system(Java Message Service) using ActiveMQ. Provide the necessary code.

Develop a simple point-to-point Message communication system(Java Message Service) using ActiveMQ. Provide the necessary code.

In: Computer Science

Using C++, Write a program that will use pointer syntax to access variables, dynamically allocate memories,...

Using C++,

Write a program that will use pointer syntax to access variables, dynamically allocate memories, and pass pointers to functions.

1.            The program should ask the user to enter a size to the array.

2.            The program should dynamically allocate an array with the size.

3.            The program should then ask user to input values to the array

4.            The program should then find the maximum, display all elements forward and reversed using two different ways of pointer access

5.            The program must use functions with pointers as parameters.

6.            The manipulation/access of the array must be done through pointer syntax.

7.            Your main function should only declare the variables and call the functions.

Variable:

You’ll need the following pointer to be declared in your main function.

float * ptData;

Data Validation:

1.            The size of the array cannot be less or equal to 1 (E.g. 2, 5, 100 is fine, but 1 or 0 is no acceptable).

2.            Check if pointer has successfully allocated the array.

Functions:

               You should have separate functions to handle user input, maximum, and display the array (all the values needs to be returned to the function call, you need to have pointer as the input parameter). Main function should only call other functions.

Function Header

Explanation

void getSize(int * ptr)

This function will ask user to enter a size to the array. The size of the array cannot be less or equal to 1. For example: 2, 5, 100 is fine, but 1 or 0 is no acceptable.

float * getValues(const int SIZE)

This function will declare and use a pointer to dynamically allocate an array with the size user has entered. The pointer should be returned to the function’s call. Check if pointer has successfully allocated the array.

float getMax(const float * ptr, const int SIZE)

This function will find and return the maximum value of the array using pointer syntax.

void displayForward(const float * ptr, const int SIZE)

This function should display all array elements forward (from the first to the last)

void displayBackward(float * const ptr, const int SIZE)

This function should display all array elements backward (from last to the first)

You are required to use the following pointer and loop to accomplish this task.

float * ptr2 = ptr + SIZE;

while (ptr < ptr2)

Sample Output:

Please enter a size to the array: -9

!!!Error: an array’s size cannot be less or equal to 1

Please enter a size to the array: 6

Please enter all values of the array:

Value 1: 4

Value 2: 5

Value 3: 7

Value 4: 2

Value 5: 1

Value 6: 8

Displaying all values forward:

4    5    7    2    1    8

Displaying all values backward:

8    1    2    7    5    4   

The maximum value of this array is: 8

In: Computer Science

A load ZL = 80− j100 is located at z = 0 on a lossless 50-...

A load ZL = 80− j100 is located at z = 0 on a lossless 50- line.
The operating frequency is 200 MHz and the wavelength on the line is 2 m.
(a) If the line is 0.8 m in length, use the Smith chart to find the input impedance.
(b) What is s? (c) What is the distance from the load to the nearest voltage
maximum? (d) What is the distance from the input to the nearest point at which
the remainder of the line could be replaced by a pure resistance?

In: Computer Science

Using C# Create a class called CreditAccount. When user create this account, she/he need to enter...

Using C#

Create a class called CreditAccount. When user create this account, she/he need to enter sum of credit and loan repayment period in months. Monthly payment need to calculate using bank percentage. You must come up with a formula for calculating percentage, you can use any formula, you want.

In: Computer Science

This week we really want to learn about a file I/O in Java. In Java: 1)...

This week we really want to learn about a file I/O in Java.

In Java:

1) Create a plain empty text file named contacts.

2) Populate the text file with a person's name and account number on each line(Joe Doe 123456789). Create 10 accounts.

3) Store that file in the same location as your project

4) Write a program that will find that file and load it into the computers memory.

5) Read each line of the file and print the associated name but NOT the account number (remember the account number is 9 characters fixed)

In: Computer Science

Write a python program to create a list of integers using random function. Use map function...

Write a python program to create a list of integers using random function. Use map function to process the list on the series: x + x2/2! + x3/3! + ….n and store the mapped elements in another list. Assume the value of n as 10

In: Computer Science