Questions
Define what an array index value is in JAVA. Then, write a JAVA program that passes...

Define what an array index value is in JAVA. Then, write a JAVA program that passes an array to a method and finds the average value or mean value (add up the numbers in the array and divide by the number of values) of the array and prints it out.

In: Computer Science

Hello I'm currently having an error that says "main is not abstract and does not override...

Hello I'm currently having an error that says "main is not abstract and does not override abstract method" is there a way to fix the error?

import java.io.IOException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import static javafx.application.Application.launch;
import javafx.scene.layout.StackPane;
public class Main extends Application implements EventHandler<ActionEvent>{
    public static void main(String[] args){
        launch(args);
    }
    @Override
    public void Start(Stage stage){
        stage.setTitle("Test");
        Button calcButton = new Button("Steam");
      
        StackPane root = new StackPane();
        calcButton.setOnAction(this);
      
        Scene scene = new Scene(root, 100, 100);
      
        stage.setScene(scene);
        stage.setTitle("Test");      
        stage.show();

    }
    class CalcButtonHandle {
      
        public void handle(ActionEvent event) throws IOException
        {
        Main fo = new Main();
        fo.runOt("D:\\Steam\\Steam.exe");
        }
    }
  
    public void runOt(String path) throws IOException{
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path);
    }
}
  

In: Computer Science

Please use Java language in an easy way with comments! Thanks! Create a calculator that uses...

Please use Java language in an easy way with comments! Thanks!

Create a calculator that uses an array of buttons for numbers from 0-9, the . for decimals, and for operators +, -, * ,/ and = as well as a JTextfield that displays the current value or the result. Use ActionListeners and LayoutManagers appropriately.

The example below shows how to determine which button has been clicked.

ActionListener actionListener = new ActionListener()
 {
     public void actionPerformed(ActionEvent actionEvent) 
     {
        System.out.println(actionEvent.getActionCommand());
     }
 };

In: Computer Science

Due Thursday  (Normal late penalties apply for late submission.) Respond to the following in a minimum of...

Due Thursday  (Normal late penalties apply for late submission.)

Respond to the following in a minimum of 175 words (20 points):

Today's datacenters are populated with not only physical hardware but systems hosting virtual machines and containers. These systems communicate locally and around the globe over networks.

Discuss two different examples of threats to various parts of heterogeneous architectures and how they might manifest. Do not forget about the hardware, operating systems, applications, networks, and other integral parts. Discuss the threats in your classmates' posts.

In: Computer Science

Could you please write an article on Software Engineering Trends in about 300 words? Please, also...

Could you please write an article on Software Engineering Trends in about 300 words? Please, also provide appropriate references. Please, do not plagiarize your answer.

In: Computer Science

A)Given a generic array with ‘n’ items (not only integers). Give a solution for checking whether...

A)Given a generic array with ‘n’ items (not only integers). Give a solution for checking whether there are any duplicate elements in the array or not? You just need to return a boolean (true or false). State the complexity of your solution. Can you come up with another solution that has O(n logn) complexity? Explain.

B) Now consider the same problem as Question A, but this time you only have positive integer numbers ranging from 0 to (n-1) in the array. Can you find a duplicate in O(n) complexity? Implement the solution.

In: Computer Science

Explain virtualization as a key technology in cloud computing environments, as well as the purpose of...

Explain virtualization as a key technology in cloud computing environments, as well as the purpose of a virtualization environment.

In: Computer Science

A system is set up to take raw grading information from the console and calculate a...

A system is set up to take raw grading information from the console and calculate a consolidated grade. The information comes in as a single line with last name, first name, homework grade ( a total out of 20 ), lab grade ( a total out of 50 ), exam grade average, and a letter ( upper or lower ) indicating Audit, Passfail, or Grade.

Sample input:                    Mary(first name) Poppins(last name) g(indication) 17(homework grade) 28(lab grade) 87(exam grade)

A program should be written that takes the input data and calculates a consolidated grade based upon 10% Homework, 20 % Lab , and 70% Exams. The output should be formatted with no decimals.

first initial last name - final grade  

for a pass/fail student output should indicate only Pass or Fail . For an audit output should say not gradeable.

Using C++

In: Computer Science

I have an 8 by 8 array that has values ranging from 1-64. I am wanting...

I have an 8 by 8 array that has values ranging from 1-64. I am wanting to display the array evenly but due to some digits being single and others double, it displays lopsided. What would be the best way to get everything in the array to display in a nice even square?

In: Computer Science

Which business or industry sectors have the most startups companies that consider a small and medium...

Which business or industry sectors have the most startups companies that consider a small and medium enterprise (SME's)? To what extent the enterprise systems is important in this era? please support your answer by giving an example?

In: Computer Science

Explain how advances in technology can force a software subsystem to undergo change or run the...

Explain how advances in technology can force a software subsystem to undergo change or run the risk of becoming useless.

In: Computer Science

Look up and use each of these Linux commands. (Each command will have two parts) Summarize...

  1. Look up and use each of these Linux commands. (Each command will have two parts)
    • Summarize their function then use the command
    • Use the Command and document the output (<parameters of your choice>
    • Command Function
      info cat
      Demonstrate 'cat' in use  
      man cp
      Demonstrate 'cp' in use  
      man touch
      Demonstrate 'touch' in use  
      man mv
      Demonstrate 'mv' in use  
      man rm
      Demonstrate 'rm' in use  
      info wc
      Demonstrate 'wc' in use  
      man find
      Demonstrate 'find' in use  
      man chmod
      Demonstrate 'chmod' in use  
      man chown
      Demonstrate 'chown' in use
      Lookup append ">>" operator online
      Demonstrate '>>' in use  
      Lookup redirection ">" operator online
      Demonstrate '>' in use  
      Lookup another command not previously covered
      Use that command

PART B (50 total pts) - File Operations (Windows)

  1. Look up and use each of these MSDOS commands. (Each command will have two parts).
    • Summarize their function then use the command
    • Use the Command and document the output
    • Command Function
      help type
      Demonstrate 'type' in use  
      help copy
      Demonstrate 'copy' in use  
      help xcopy
      Demonstrate 'xcopy' in use  
      help move
      Demonstrate 'move' in use  
      help del
      Demonstrate 'del' in use  
      Demonstrate 'find' in use  
      Demonstrate 'find' with parameters to get Word Count
      help attrib
      Demonstrate 'attrib' with parameters to get Word Count
      help rmdir
      Demonstrate 'rmdir' with parameters to get Word Count
      Look append ">>" operator online
      Demonstrate '>>' in use
      Look redirection ">" operator online
      Demonstrate '>' in use  
      help whoami
      Demonstrate 'whoami' in use  
      Lookup another command not previously covered
      Use that command

In: Computer Science

Our next optimization comes from using the brilliant Rabin-Karp substring matching algorithm (RK for short), invented...

Our next optimization comes from using the brilliant Rabin-Karp substring matching algorithm (RK for short), invented in the eighties by two famous computer scientists, Michael Rabin and Richard Karp 3. RK checks if a given query string P appears as a substring in Y. At a high level, RK works by computing a hash for the query string, hash(P ), as well as a hash for each of the n − k + 1substrings of length k in Y, hash(Y [0...k − 1]), hash(Y [1...k]), ..., hash(Y [n − k...n − 1]). A hash function turns any arbitrary string into a b-bit hash value with the property that collision (two different strings with the same hash value) is unlikely. Therefore, by comparing hash (P) with each of the n − k + 1 hashes from Y, we can check if P appears as a substring in Y. There are many nice hash functions out there (such as MD5, SHA-1), but RK's magical ingredient is its "rolling" hash function. Specifically, given hash(Y [i...i + k − 1]), it takes only constant time instead of O(k) time to compute hash(Y [i + 1...i + k]). Now we explain how the rolling hash is computed. Let's treat each character as a digit in radix-d notation. We choose radix d = 256 since each character in the C language is represented by a single byte and we can conveniently use the byte value of the character as its digit. For example, the string 'ab' corresponds to two digits with one being 97 (the ASCII value of 'a'), and the other being 98 (the ASCII value of 'b'). The decimal value of 'ab' in radix-256 can be calculated as 256 ∗ 97 + 98 = 24930. The hash of a string P in RK is hash(P[0...k−1])=256?−1 ∗P[0]+256?−2∗P[1]+...+256∗P[k−2]+P[k−1]].

COMPLETE THE RABIN_KARP MATCH FUNCTION ONLY

Now let's see how to do a rolling calculation of the values for every substring of Y.

Let ?? = hash(Y [0...k − 1] and yi = hash(Y [i...i + k − 1]). We can compute ??+1 from ?? in constant time, by observing that

??+1 =256∗(?? −256?−1∗Y[i])+Y[i+k]

Note that we have to remember the value of 256?−1 in a variable instead of re-computing it for?? each time. Now we've seen how rolling hash works. The only fly in the ointment is that these radix-256 hash values are too huge to work with efficiently and conveniently. Therefore, we perform all the computation in modulo q, where q is chosen to be a ????? 4 ????? 5. Hash collisions are infrequent, but still possible. Therefore once we detect some ?? = hash(P ), we should compare the actual strings Y [i...i + k − 1] and P [0...k − 1] to see if they are indeed identical. Since RK speeds up substring matching to O(n) on average instead of O(n ∗ k) as in the simple algorithm. However, we still need to run RK [?? ] times for each of the [?? ] chunks of X to be matched in Y. Thus, our approximate matching algorithm using RK has an overall runtimeO ( ?? * n )

Your job: Implement the RK substring matching algorithm by completing therabin_karp_match for each chunk of X to bet matched. When calculating the hash values, you should use the given modulo arithmetic functions madd, mdel, mul

As with simple_match, our main procedure will invoke rabin_karp_match for each chunk of X to be matched. rabin_karp_match has the same interface as simple_match and should return 1 if the chunk appears as a substring in Y or 0 if otherwise.

Complete the following function:

* Match every k-character snippet of the query_doc document
   among a collection of documents doc1, doc2, ....

   ./rkmatch snippet_size query_doc doc1 [doc2...]

*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <strings.h>
#include <assert.h>
#include <time.h>
#include <ctype.h>

#include "bloom.h"

enum algotype { SIMPLE = 0, RK, RKBATCH};

/* a large prime for RK hash (BIG_PRIME*256 does not overflow)*/
long long BIG_PRIME = 5003943032159437;

/* constants used for printing debug information */
const int PRINT_RK_HASH = 5;
const int PRINT_BLOOM_BITS = 160;

/* modulo addition */
long long
madd(long long a, long long b)
{
   return ((a+b)>BIG_PRIME?(a+b-BIG_PRIME):(a+b));
}

/* modulo substraction */
long long
mdel(long long a, long long b)
{
   return ((a>b)?(a-b):(a+BIG_PRIME-b));
}

/* modulo multiplication*/
long long
mmul(long long a, long long b)
{
   return ((a*b) % BIG_PRIME);
}

/* read the entire content of the file 'fname' into a
   character array allocated by this procedure.
   Upon return, *doc contains the address of the character array
   *doc_len contains the length of the array
   */
void
read_file(const char *fname, char **doc, int *doc_len)
{
   struct stat st;
   int fd;
   int n = 0;

   fd = open(fname, O_RDONLY);
   if (fd < 0) {
       perror("read_file: open ");
       exit(1);
   }

   if (fstat(fd, &st) != 0) {
       perror("read_file: fstat ");
       exit(1);
   }

   *doc = (char *)malloc(st.st_size);
   if (!(*doc)) {
       fprintf(stderr, " failed to allocate %d bytes. No memory\n", (int)st.st_size);
       exit(1);
   }

   n = read(fd, *doc, st.st_size);
   if (n < 0) {
       perror("read_file: read ");
       exit(1);
   }else if (n != st.st_size) {
       fprintf(stderr,"read_file: short read!\n");
       exit(1);
   }
  
   close(fd);
   *doc_len = n;
}


/* The normalize procedure examines a character array of size len
   in ONE PASS and does the following:
   1) turn all upper case letters into lower case ones
   2) turn any white-space character into a space character and,
   shrink any n>1 consecutive spaces into exactly 1 space only
           Hint: use C library function isspace()
   You must do the normalization IN PLACE so that when the procedure
   returns, the character array buf contains the normalized string and
   the return value is the length of the normalized string.
*/
int
normalize(char *buf,   /* The character array containing the string to be normalized*/
                   int len           /* the size of the original character array */)
{
   int start_index=0; //starting index
   int new_index=0; //index returning the new position

   //for loop iterating over the characters in the array
   for (start_index=0;start_index<len;start_index++)
   {
       //checks if the character is an uppercase
       if(isupper(buf[start_index]))
       {
           buf[new_index++]=tolower(buf[start_index]); //coverts the upper case character to a lower case and the new index changes position
       }
       else if (!isupper(buf[start_index])&& !isspace(buf[start_index])) //handles if its not an upper case and not a space
       {
           buf[new_index++]=buf[start_index];
       }

       //removes the consecutive spaces
       else if(isspace(buf[start_index])){
           if ((start_index>0) && (start_index < (len-1)) && !isspace(buf[start_index-1])){
               buf[new_index++]=' ';

           }

   }
}

//removes the trailing spaces at the end
if (isspace(buf[len-1])) //if the last character is a string
{
   return new_index-1; //returns the character before the last that is not a space
}

else{

   return new_index;
}
}

/* check if a query string ps (of length k) appears
   in ts (of length n) as a substring
   If so, return 1. Else return 0
   You may want to use the library function strncmp
   */
int
simple_match(const char *ps,   /* the query string */
                       int k,                    /* the length of the query string */
                       const char *ts,   /* the document string (Y) */
                       int n                       /* the length of the document Y */)
{
   int i;
   for (i=0;i<n;i++){ //for loop iterating
       if (strncmp(&ts[i],ps,k)==0) //library function that compares if the query string appears in the other document
       {
           return 1; //if it matches it will return 1
       }
   }
  
   return 0; //if it doesnt, it returns 0
}
      

/* Check if a query string ps (of length k) appears
   in ts (of length n) as a substring using the rabin-karp algorithm
   If so, return 1. Else return 0
   In addition, print the first 'PRINT_RK_HASH' hash values of ts
   Example:
   $ ./rkmatch -t 1 -k 20 X Y
   605818861882592 812687061542252 1113263531943837 1168659952685767 4992125708617222
   0.01 matched: 1 out of 148
   */

COMPLETE THIS FUNCTION ONLY
int
rabin_karp_match(const char *ps,   /* the query string */
                               int k,                    /* the length of the query string */
                               const char *ts,   /* the document string (Y) */
                               int n                       /* the length of the document Y */ )
{
   return 0;
}

/* Initialize the bitmap for the bloom filter using bloom_init().
   Insert all m/k RK hashes of qs into the bloom filter using bloom_add().
   Then, compute each of the n-k+1 RK hashes of ts and check if it's in the filter using bloom_query().
   Use the given procedure, hash_i(i, p), to compute the i-th bloom filter hash value for the RK value p.

   Return the number of matched chunks.
   Additionally, print out the first PRINT_BLOOM_BITS of the bloom filter using the given bloom_print
   after inserting m/k substrings from qs.
*/
int
rabin_karp_batchmatch(int bsz, /* size of bitmap (in bits) to be used */
int k, /* chunk length to be matched */
const char *qs, /* query docoument (X)*/
int m, /* query document length */
const char *ts, /* to-be-matched document (Y) */
int n /* to-be-matched document length*/)
{
   return 0;
}

In: Computer Science

Search the Internet to find (at least 2 websites) related to the general field of malware....

Search the Internet to find (at least 2 websites) related to the general field of malware. Please provide a brief synopsis of the website. Post the links

In: Computer Science

Consider the following schema: Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost) write the following...

Consider the following schema:

Suppliers(sid, sname, address)

Parts(pid, pname, color)

Catalog(sid, pid, cost)

write the following queries in SQL:

* Find the names of all suppliers who supply a green part.

*Find the names of all suppliers who are from Illinois.

*Find the names of all suppliers who sell a red part costing less than $100.

*Find the names and colors of all parts that are green or red.

In writing these queries you may make the following assumptions:

a. Each part has only one color.
b. A cost field is a real number with two decimal places (e.g., 100.25, 93.00).
c. The sid field in Suppliers and the sid field in Catalog refer to the same field.
d. The
pid field in Parts and the pid field in Catalog refer to the same field.

In: Computer Science