Questions
In Java. Create a class called FileSumWrapper with a method that has the signature public static...

In Java.

Create a class called FileSumWrapper with a method that has the signature

public static void handle(String filename, int lowerBound)

Make this method call FileSum.read and make your method catch all the errors.

FileSum.read is a method that takes a filename and a lower bound, then sums up all the numbers in that file that are equal to or above the given lower bound.

FileSum :

import java.io.File;
import java.rmi.UnexpectedException;
import java.util.Scanner;

public class FileSum {

    public static int read(String filename, int lowerBound) throws Exception {
        Scanner inputFile = new Scanner(new File(filename));

        int acc = 0;
        boolean atLeastOneFound = false;
        while (inputFile.hasNext()) {
            int data = inputFile.nextInt();
            if (data >= lowerBound) {
                acc += data;
                atLeastOneFound = true;
            }
        }

        if (!atLeastOneFound) {
            throw new UnexpectedException("");
        }

        return acc;
    }

}

Question1:

import java.util.Scanner;

public class Question1 {

    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter a filename");
        String filename = keyboard.nextLine();
        System.out.println("Enter a lower bound");
        int lowerBound = keyboard.nextInt();

        FileSumWrapper.handle(filename, lowerBound);
    }
}

err.txt :

50 40 30
90
85
23
06
30x
54
675
875
34
2323
423
423
5
5
79
97
90y
7986
5
46
64656
66
6
333 93 9 300 20 2 9 209 290 39 48 85 7847 578048

t1.txt:

50 40 30
90
85
23
06
30x
54
675
875
34
2323
423
423
5
5
79
97
90y
7986
5
46
64656
66
6
333 93 9 300 20 2 9 209 290 39 48 85 7847 578048

Here is the input :

t1.txt
50

output:

Enter a filename\n
Enter a lower bound\n
Sum of all numbers in t1.txt is 665177\n

In: Computer Science

Write, test, and debug (if necessary) HTML file with the Javascript codes in an external file...

Write, test, and debug (if necessary) HTML file with the Javascript codes in an external file for the following problem:

Input: a number, n, using prompt, which is the number of the factorial numbers to be displayed.

Output: a bordered table of numbers with proper caption and headings in which the first column displays the numbers from 1 to n and the second column displays the first n factorial numbers.

For example, if a user enters 10 to be the value of n, the first column will include 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and the second column will include 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800.

Your Javascript codes must include a function to compute the factorial number given an input number. This function is to be called to generate corresponding factorial number for each number in the first column of the table. You must use document.write to produce the desired output. Use the external CSS document for the display of the table.

In: Computer Science

There are four tables in the database. 1. students (sno, sname, sgender, sbirthday, class) - sno:...

There are four tables in the database.

1. students (sno, sname, sgender, sbirthday, class)

- sno: student number

- sname: student name

- sgender: male or female

- sbirthday: date of birth

- class: class number

- primary key: sno

2. courses (cno, cname, tno)

- cno: course number

- cname: course name

- tno: teacher number

- primary key, cno, tno

3. scores (sno, cno, grade)

- sno: student number

- cno: course number

- grade: grade

- primary key, sno, cno

4. teachers (tno, tname, tgender, tbirthday, title, department)

- tno: teacher number

- tname: teacher name

- tgender: teacher gender

- tbirthday: date of birth

- title: title of the teacher, e.g. professor, lecture, or TA

- department: department name, e.g. CS, EE.

Question 1: In the score table, find the student number that has all the grades in between 90 and 70.

Question 2: For all the courses that took by class 15033, calculate the average grade.

Question 3: Find the class number that has at least two male students.

Question 4: Find the teacher's name in CS and EE department, where they have different title. Return both name and title.

Question 5: Find the students, who took the course number "3-105" and have earned a grade, at least, higher than the students who took "3- 245" course. Return the results in a descending order of grade.

Question 6: Find the students, who took more than 1 course, and return the students' names that is not the one with highest grade.

Question 7: For each course, find the students who earned a grade less than the average grade of this course.

In: Computer Science

Design and implement an algorithm that gets as input a list of k integer values N1,...

Design and implement an algorithm that gets as input a list of k integer values N1, N2, …., Nk, as well as a special value SUM. Your algorithm must locate a pair of values in the list N that sum to the value SUM. For example, If your list of values is 3, 8, 13, 2, 17, 18, 10, and the value of SUM is 20, then your algorithm would output either of the two values (2, 18) or (3, 17). If your algorithm cannot find any pair of values that sum to the value of SUM, then it should print the message ‘Sorry there is no such pair of values.’

In: Computer Science

A painting company has determined that for every 115 square feet of wall space, one gallon...

A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $20.00 per hour for labor. Design a modular program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon.

The program should display the following data:

The number of gallons of paint required

The hours of labor required

The cost of the paint

The labor charges T

he total cost of the paint job

Using Python

In: Computer Science

In python idle 3.9.0 write a function that: i) will count all lower case, upper case,...

In python idle 3.9.0 write a function that:

i) will count all lower case, upper case, integers, and special symbols from a given string. The input string is provided by the user.

ii) will check if a sting is a palindrome. User supplies the input string.

In: Computer Science

In this assignment, you need to demonstrate your ability in using input, output, data types, and...

In this assignment, you need to demonstrate your ability in using input, output, data types, and if statement in C++ program. Assume that you need write a C++ program for a cash register. There are only four items in the store: Cereal, $3.99 Milk, $3.99 Egg, $0.25 Water, $ 1.50 Once a customer purchases items, you will ask her/his how many of them are bought. The quantity can be in the range of 0-10 (including 0 and 10). Then, calculate total for this transaction. Later ask for payment method, which could be either Credit Card or Cash. Do not use string variables. Just use char variables, for instance “1” for Credit Card, “2” for Cash. If the payment method is CC, your program exits. If it is cash, and enter the amount received from customer. Then show the due amount the customer. An example scenario for a CC payment: Enter how many cereal boxes customer bought:2 Enter how many milk jars customer bought:1 Enter how many eggs customer bought:3 Enter how many water bottles customer bought:0 Total is $12.72 Payment Method: 1 Thanks... An example scenario for a cash payment: Enter how many cereal boxes customer bought:1 Enter how many milk jars customer bought:0 Enter how many eggs customer bought:6 Enter how many water bottles customer bought:5 Total is $12.99 Payment Method: 2 Enter the amount received from customer: 20.00 Due amount is $7.01 Thanks...

In: Computer Science

Show that every 2-tree with n internal nodes has n+ 1 external nodes

Show that every 2-tree with n internal nodes has n+ 1 external nodes

In: Computer Science

Given a string, such as x = ‘itm330’, write a Python program to count the number...

Given a string, such as x = ‘itm330’, write a Python program to count the number of digits and the number of letters in it. For example, in ‘itm330’, there are 3 letters and 3 digits.

Hint: Very similar to page 11 on the slides. To check if a character c is a digit, use c.isdigit(). If c is a digit, c.isdigit() will be a True.

In: Computer Science

Create a java program that has a code file with main() in it and another code...

Create a java program that has a code file with main() in it and another code file with a separate class. You will be creating objects of the class in the running program, just as the chapter example creates objects of the Account class.

Your system handles employee records and processes payroll for them. Create a class called Employee that holds the following information: first name, last name, monthly salary, and sales bonus. The class should have all the gets and sets and have a method to report the yearly salary (which is the monthly salary * 12 + the sales bonus.)

[Note: Before anyone asks. You cannot have spaces in variable names. So you might call the first one firstName, first_name, fname or any other appropriate and legal variable name. The write up above is telling you the information to be stored in English, not java.]

Create 2 objects of Employee in your main code class and display their names, monthly, and yearly salaries. Then give them each a 100 pay raise to their monthly salary. (Hint: use the get() to read it out to a variable, add 100, then use the set() to store it back in) Then display their names, monthly, and yearly salaries again.

[Note2: You can hard code the names, and salaries you are storing in the 2 employee objects or ask the user for them with a Scanner. Either way is fine. It is perfectly all right from a grading standpoint to just give it test values like the chapter example does.]

Please use beginner level Java and NetBeans 8.0

In: Computer Science

For this problem, write a Ruby script named arr2cols.rb that prints an array’s contents as formatted...

For this problem, write a Ruby script named arr2cols.rb that prints an array’s contents as formatted rows and columns. The data is provided by the predefined arrays below: escargot_player_data, employees, andartists. Your script must work with all three arrays.

The number of columns in the data will be consistent within each data set, but each dataset will have a different number of columns. We can the use Array#each method to iterate all of the elements in an array. each will give us each element in the order it appears in the array.

Your script should work with all these three arrays of data: escargot_player_data, employees, and artists.

Array 1: Escargot Players Data The escargot_player data is a multidimensional array with each sub-array containing three strings.

# A array containing Escargot player data
escargot_player_data = [
  # Column names: name, character, and points
  ['Jim','bullfrog',99],
  ['Mack the Knife','caterpillar',12],
  ['Willy','chihuahua',143],
  ['Trudy','bunny',3],
  ['Mary Lou','slow loris',1443],
  ['Sharon Stone','komodo dragon',8888],
]

Array 2: Employee data The employees array is a multidimensional array containing rows with six elements.

employees = [
    #  Name Address City State SSN Telephone
    %w(Walter\ White 123\ Happy\ Home\ Drive Albuquerque NM 555-66-7777 505-123-4567 ),
    %w(Jesse\ Pinkman 43\ Cloudy\ Skies\ Parkway Albuquerque NM  666-12-3456, 505-888-9999 ),
    %w(Gustavo\ Fring 123\ Pollos\ Boulevard Albuquerque NM 565-32-3344 505-434-9001 ),
    %w(Tuco\ Salamanca 99\ Crystal\ Springs\ Lane Albuquerque NM 575-44-3553 505-776-0455 ),
    %w(Saul\ Goodman 9800\ Montgomery\ Blvd\ NE Albuquerque NM 585-19-9990 505-503-4455 )
]

Array 3: Artist Addresses and Income The artists array is a multidimensional array with 9 elements in each sub array.

artists = [
   # column names
   %w( first_name last_name telephone address city state zip_code birthdate salary ),

   [ 'Vinh',
     'Tranh',
     '438-910-7449',
     '8235 Maple Street',
     'Wilmington',
     'VM',
     '29085',
     '9/23/63',
     '1200'
   ],

   [ 'William',
     'Kopf',
     '846-836-2837',
     '6937 Ware Road',
     'Milton',
     'PA',
     '93756',
     '9/21/46',
     '43500'
   ],

   [ 'Yukio',
     'Takeshida',
     '387-827-1095',
     '13 Uno Lane',
     'Ashville',
     'NC',
     '23556',
     '7/1/29',
     '57000'
   ],

   [ 'Zippy',
     'Pinhead',
     '834-823-8319',
     '2356 Bizarro Ave.',
     'Farmount',
     'IL',
     '84357',
     '1/1/67',
     '89500'
   ],
   [ 'Andy',
     'Warhol',
     '212-321-7654',
     '231 East 47th Street',
     'New York City',
     'NY',
     '10017',
     '8/6/1928',
     '2700000' 
   ]
]

3.1 arr2cols.rb code to get you started

# Start building the table by concatenation
#!/usr/local/bin/ruby
# Name: Your Name
# File: arr2cols.rb
# Desc: Uses Array methods to manipulate an array created from a string
#       Example tables: escargot_player_data, employees, and artists 

# 1. Code from Lab 1 to fetch the_string from a URL
# 2. Add the pre-defined arrays here.

all_arrays = [ escargot_player_data, employees, artists ]

# Iterate through the array of players one row at a time
all_arrays.each do |array|

  # Print everything in columns

end

In: Computer Science

1. Create a class Point which has a template parameter of the type of internal data,...

1. Create a class Point which has a template parameter of the type of internal data, T, and a template parameter for the dimension of the Point(2D, 3D etc.). Store a statically allocated, internal array of type T with dimension n. Ensure to include any constructer(s),destructors, getters or setters you might need.

2. Create a template function which computes the Euclidean distance between 2 points.

3. Instantiate two Point and compute their distance. Instantiate two Point and compute their distance.

Please have a .h and .cpp file and follow the instructions precisely thank you!

Edit: the value for n (size of internal array) should that be 2

In: Computer Science

[Wireshark ] Using the Wireshark program, capture all the network traffic that is related to opening...

  1. [Wireshark ] Using the Wireshark program, capture all the network traffic that is related to opening a webpage of your choice. In order to get maximum benefit/knowledge from the assignment, it’s recommended to choose a non-trivial web portal for the assignment. Using the captured information (Wireshark Capture), answer the questions below. Explain your answer.
    1. Define a display filter that finds the DNS queries and DNS responses. Narrow down the filter so that only these DNS packets are shown that were necessary for opening your chosen webpage (the captured DNS packets that were related to other applications/clients in your computer should be left out of the list).
    2. Define a display filter that finds the TCP packets.
    3. Narrow down the filter even more, so that only these TCP packets are shown that were used to create a new TCP connection(the TCP packets that were following each connection establishment, should be left out of the list).
    4. Using the filter from the previous step, list all the TCP connections that were necessary for opening your chosen webpage. For each TCP connection, explain the following (you can group the connections, to avoid repetitions in your explanations):
    • local(client) TCP port number,
    • remote(server) TCP port number,
    • remote(server) IP address
    • The source and destination MAC address of all the outgoing packets? Whyare all the outgoing packets going to this particular MAC address?
  1. If you can run “traceroute/tracert” between machines in your organization. List three concrete applications to use trace route for cybersecurity?
  1. How to use ”netstate/netstat” to discover malicious activities in your machine?
  1. Install and use Process Monitor “Procmon” (you can download from https://docs.microsoft.com/en-us/sysinternals/ (Links to an external site.)) and then show how to list all running processes that run “RegCreateKey” operation with unsuccessful results.
  1. Show how to use Nmap to do IP scanning using TCP and ICMP and port scanning using Stealth FIN. Show the command and the output.
  1. (extra credit) Use Nessus to discover a vulnerability on a real network

In: Computer Science

Suppose you are an analyst for the Roanoke Software Consulting Company (RSCC), a large consulting firm...

Suppose you are an analyst for the Roanoke Software

Consulting Company (RSCC), a large consulting firm with

offices around the world.

The company wants to build a

new knowledge management system that can identify and

track the expertise of individual consultants anywhere in

the world based on their education and the various

consulting projects on which they have worked

. Assume

that this is a new idea that never done before been

attempted in RSCC or elsewhere. RSCC has an

international network, but the offices in each country may

use somewhat different hardware and software. RSCC

management wants the system up and running within a

year.

In: Computer Science

c++ Write a program that print stars, Max and Min values. It should use the following...

c++

Write a program that print stars, Max and Min values. It should use the following functions:

  1. (2 pts) int getNum ( ) should ask the user for a number and return the number. This function should be called by main once for each number to be entered. Input Validation: Do not accept numbers less than -100.
  2. (2 pts) void printStars ( int n ) should print n number of stars. If n is less than 0, display "Invalid" message instead.
  3. (5 pts) main ( ) should call getNum ( ) function each time to read the user input. Pass each user input into printStars ( ) function to print stars. This function will loop to process series of integers.
    • (2 pts) When the user input is -99, that's a signal to terminate the loop (end of the user inputs (sentinel value)). Remember, sentinel value should not be processed as part of user inputs.
    • (2 pts) main ( ) should also display overall Min and Max values of user inputs.
  4. (1 pt) Write the function prototypes for getNum ( ) and printStars ( ) functions.

Sample runs :

(Bold underlined numbers below are sample user inputs. Your program should display the exact output given the same user inputs)

Please enter a number : -99
Exiting the program....

// restart the program here and the output is as follows: 
Please enter a number : 1
*
Please enter a number : 2
**
Please enter a number : 3
***
Please enter a number : -99

Min = 1, Max = 3
Exiting the program....

// restart the program here and the output is as follows: 
Please enter a number : -1
Invalid
Please enter a number : 10
**********
Please enter a number : -33
Invalid
Please enter a number : 5
*****
Please enter a number : -99

Min = -33, Max = 10
Exiting the program....

In: Computer Science