Questions
Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask...

  1. Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask the player to find each of a given set of words in a square table filled with single letters. A word can read horizontally (left or right), vertically (up or down), or along a 45 degree diagonal (in any of the four directions) formed by consecutively adjacent cells of the table; it may wrap around the table’s boundaries, but it must read in the same direction with no zigzagging. The same cell of the table may be used in different words, but, in a given word, the same cell may be used no more than once. Write a computer program for solving this puzzle.

In: Computer Science

Identify and explain both internal and external reasons why change is inevitable in any organization.

Identify and explain both internal and external reasons why change is inevitable in any organization.

In: Computer Science

Map word scanning in C++ For some context, I've been working on a program in which...

Map word scanning in C++

For some context, I've been working on a program in which I must enter in words and clear them of any potential punctuations. If a word has punctuation in the middle of the word, I must ignore the letters AFTER the punctuation and delete the punctuation as well. For example if I enter in "fish_net" I will only get "fish" back. I must also keep track of the occurrence of each word as well as number of words.

Here's my problem, I'm using a do while loop to continuously enter in words and break from it when needed. When I do, my output is supposed to be separate words, but they are getting merged with each other and counting it as one word. For example, lets say I enter in the words: "hello" "there" "done". The INTENDED output should be the following: hello 1 (newline) there 1 (newline) done 1. However, the output CURRENTLY goes like this: hello 1 (newline) hellothere 1 (newline) hellotheredone 1. Mind you that the numbers after the words are the number of occurrences that word is entered.

#include <iostream>
#include<map>
#include<string>
#include <algorithm>
using namespace std;

void get_words(map<string, int>&);
void print_words(const map<string, int>&);
void clean_entry(const string&, string&);

int main()
{
   map<string,int>m;
   get_words(m);
   print_words(m);
}

void get_words(map<string, int>&m)
{
   string word, cleaned_words = "";
   cout << "Enter in a string of text: ";
   do
   {  
       cin >> word;
       clean_entry(word, cleaned_words);

       if (cleaned_words.length() != 0)
       {
           m[cleaned_words]++;//inserting clean words into map
       }
  
   } while (word != "done");
}

void print_words(const map<string, int>&m)
{  
   int non_empty_words = 0;
   for (auto it = m.begin(); it != m.end(); it++)
   {
       cout << it->first << " " << it->second << endl;
       non_empty_words += it->second;
   }
   cout << "Non-empty words: " << non_empty_words << endl;
   cout << "Words: " << m.size();
}

void clean_entry(const string&words, string&cleaned_words)
{
   int len = words.length();
   int i = 0;
   while (i < len && ispunct(words[i])) i++;//parse through initial punctuation (make sure that punctuation is deleted while leaving word intact if in front or back)
   while (i < len && !ispunct(words[i]))//while we come across any words with no punctuation, we add it to cleaned words
   {
       cleaned_words += words[i];
       i++;
   }
}

In: Computer Science

Explain briefly how search engines work (What are the major components?).

Explain briefly how search engines work (What are the major components?).

In: Computer Science

Generational learning experts describe potential entrepreneurs in four categories, Millenials, Generation X, Baby Boomers and Silent...

Generational learning experts describe potential entrepreneurs in four categories, Millenials, Generation X, Baby Boomers and Silent Generation.
Please distinguish between these generations and state which one is currently more inclined to start a new venture

In: Computer Science

For a project I have to implement a class called BigInteger, with a representative small set...

For a project I have to implement a class called BigInteger, with a representative small set of operations. (working with big integers that is far more digits that java's int data type will allow. Here's the code, including what I have so far. I would appreciate any help. thank you. i'm not sure if what i have is right (the only thing i wrote is under the public static BigInteger parse(String integer) we just have to implement that method.

package bigint;

/** * This class encapsulates a BigInteger, i.e. a positive or negative integer with * any number of digits, which overcomes the computer storage length limitation of * an integer. * */

public class BigInteger {

/** * True if this is a negative integer */

boolean negative;

/** * Number of digits in this integer

*/ int numDigits; /** * Reference to the first node of this integer's linked list representation * NOTE: The linked list stores the Least Significant Digit in the FIRST node. * For instance, the integer 235 would be stored as: * 5 --> 3 --> 2 * * Insignificant digits are not stored. So the integer 00235 will be stored as: * 5 --> 3 --> 2 (No zeros after the last 2) */

DigitNode front; /** * Initializes this integer to a positive number with zero digits, in other * words this is the 0 (zero) valued integer. */

public BigInteger() {

negative = false; numDigits = 0; front = null; }

/** * Parses an input integer string into a corresponding BigInteger instance. * A correctly formatted integer would have an optional sign as the first * character (no sign means positive), and at least one digit character * (including zero). * Examples of correct format, with corresponding values * Format Value * +0 0 * -0 0 * +123 123 * 1023 1023 * 0012 12 * 0 0 * -123 -123 * -001 -1 * +000 0 * * Leading and trailing spaces are ignored. So " +123 " will still parse * correctly, as +123, after ignoring leading and trailing spaces in the input * string. * * Spaces between digits are not ignored. So "12 345" will not parse as * an integer - the input is incorrectly formatted. * * An integer with value 0 will correspond to a null (empty) list - see the BigInteger * constructor * * @param integer Integer string that is to be parsed * @return BigInteger instance that stores the input integer. * @throws IllegalArgumentException If input is incorrectly formatted */

public static BigInteger parse(String integer)

throws IllegalArgumentException {

integer = integer.trim();

BigInteger bigInt = new BigInteger();

boolean negative = false; hasExplicitSign = false; int stringLength;

if(integer != null) {

stringLength = integer.length(); }else { throw new IllegalArgumentException("Please input a valid number"); }

if (stringLength==0) { throw new IllegalArgumentException("Please input a valid number"); } else

if(stringLength == 1 && integer.substring(0,1).compareTo("-") <= 0) {

throw new IllegalArgumentException("Please input a valid number."); } else

if(stringLength>0) {

int lastIndexNeg = -1; int lastIndexPos = -1;

for(int i = 0; i < stringLength; i++) {

char digitOrSign = integer.charAt(i); if(digitOrSign == '-') lastIndexNeg = i; else if(digitOrSign == '+')

lastIndexPos = i;

else if(!Character.isDigit(digitOrSign))

throw new IllegalArgumentException("Please input a valid number.");

if(lastIndexNeg > 0 || lastIndexPos > 0) {

throw new IllegalArgumentException("Please input a valid number.");

if(lastIndexNeg == 0) {

hasExplicitSign = true; negative = true; } else

if(lastIndexPos == 0) { hasExplicitSign = true; } if(hasExplicitSign) {

integer = integer.substring(1); stringLength--; }

if(stringLength==1 && integer.charAt(0) == '0') {

return bigInt; } } int lastDigit = Integer.parseInt(integer.substring(stringLength-1, stringLength));

bigInt.front = new DigitNode(lastDigit, null); } } } } /* IMPLEMENT THIS METHOD */ // following line is a placeholder for compilation return null; } /** * Adds the first and second big integers, and returns the result in a NEW BigInteger object. * DOES NOT MODIFY the input big integers. * * NOTE that either or both of the input big integers could be negative. * (Which means this method can effectively subtract as well.) * * @param first First big integer * @param second Second big integer * @return Result big integer */ public static BigInteger add(BigInteger first, BigInteger second) { /* IMPLEMENT THIS METHOD */ // following line is a placeholder for compilation return null; } /** * Returns the BigInteger obtained by multiplying the first big integer * with the second big integer * * This method DOES NOT MODIFY either of the input big integers * * @param first First big integer * @param second Second big integer * @return A new BigInteger which is the product of the first and second big integers */ public static BigInteger multiply(BigInteger first, BigInteger second) { /* IMPLEMENT THIS METHOD */ // following line is a placeholder for compilation return null; } /* (non-Javadoc) * @see java.lang.Object#toString() */

public String toString() {

if (front == null) { return "0"; }

String retval = front.digit + "";

for (DigitNode curr = front.next; curr != null; curr = curr.next)

{ retval = curr.digit + retval; }

if (negative) { retval = '-' + retval; }

return retval; } }

this is the other class digitalnode.java

package bigint;

/**
* This class encapsulates a linked list for a digit of a big integer.
public class DigitNode {
   /**
   * The digit
   */
   int digit;
  
   /**
   * Pointer to next digit in the linked list
   */
   DigitNode next;
  
   /**
   * Initializes this digit node with a digit and next pointer
   *
   * @param digit Digit
   * @param next Next pointer
   */
   DigitNode(int digit, DigitNode next) {
       this.digit = digit;
       this.next = next;
   }
  
   /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
   public String toString() {
       return digit + "";
   }
}

In: Computer Science

Can you convert this code (Python) to C++ def decrypt(message, key): decryptedText = "" for i...

Can you convert this code (Python) to C++

def decrypt(message, key):
    decryptedText = ""
    for i in message:
        M = ord(i)
        k = int(key, 16)
        xor = M ^ k
        decryptedText += chr(xor)
    return decryptedText


def encrypt(message, key):
    encryptedText = ""
    for i in message:
        M = ord(i)
        k = int(key, 16)
        xor = M ^ k
        encryptedText += chr(xor)
    return encryptedText


# main function
userText = input("Enter text: ")
userKey = str(input("Enter a key: "))
encryptedMessage = encrypt(userText, userKey)
decryptedMessage = decrypt(encryptedMessage, userKey)
print("Encrypted message: ", encryptedMessage)
print("Decrypted message: ", decryptedMessage)

In: Computer Science

I am having an issue with trying to make my code to have a required output...

I am having an issue with trying to make my code to have a required output

////////////Input//////////

With computer science, you can work in any industry.
0

//////////Output//////////

Required Output

Enter some text to encrypt\n
Enter a key\n
Error: Key is divisible by 26. That's a bad key!\n
Useless key: 0\n

///////////Cipher.java///////// ------------ My code.

public class Cipher
{
    private String plainText;
    private int key;

    public Cipher(String text, int key) throws EmptyPlainText, UselessKeyException
    {
        if (text == null || text.length() == 0)
        {
            throw new EmptyPlainText("Error: Nothing to encrypt!");
        }
        if (key % 26 == 0)
        {
            throw new UselessKeyException(26, "Error: Key is divisible by 26. That's a bad key!");
        }

        this.plainText = text;
        this.key = key;
    }

    public String getPlainText()
    {
        return plainText;
    }

    public int getKey()
    {
        return key;
    }

    public String getCipherText()
    {
        String cipher = "";
        int k = key % 26;
        char c;
        int integer;

        for (int counter = 0; counter < plainText.length(); counter++)
        {
            c = plainText.charAt(counter);
            if (Character.isUpperCase(c))
            {
                integer = c - 'A';
                integer += k;
                integer %= 26;
                c = (char) (integer + 'A');
            } else if (Character.isLowerCase(c))
            {
                integer = c - 'a';
                integer += k;
                integer %= 26;
                c = (char) (integer + 'a');
            } else
                c += k;

            cipher += c;
        }
        return cipher;
    }
}

///////////CipherDemo/////////

import java.util.Scanner;

public class CipherDemo {
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter some text to encrypt");
        String input = keyboard.nextLine();
        System.out.println("Enter a key");
        int key = keyboard.nextInt();

        try {
            Cipher c = new Cipher(input, key);
            System.out.println("Plain text: " + c.getPlainText());
            System.out.println("Cipher text: " + c.getCipherText());
            System.out.println("Key: " + c.getKey());
        } catch (EmptyPlainText e) {
            System.out.println(e.getMessage());
        } catch (UselessKeyException e) {
            System.out.println(e.getMessage());
            System.out.println("Useless key: " + e.getUselessKey());
        }
    }
}

In: Computer Science

Why did the Sarbanes–Oxley Act become law? In your opinion, does it provide any real protection...

Why did the Sarbanes–Oxley Act become law? In your opinion, does it provide any real protection to investors? Why or why not?

In: Computer Science

DoubleClick focuses on three main metrics: cost-per-click (CPC), click-through rate (CTR), and transaction conversion rate (TCR)....

DoubleClick focuses on three main metrics: cost-per-click (CPC), click-through rate (CTR), and transaction conversion rate (TCR). What other metrics can you think of that can be used to measure and compare the performance of different SEM campaigns? Explain

In: Computer Science

swapArrayEnds(int[] nums): swaps the first and last elements of its array parameter. Ex: {10, 20, 30,...

  • swapArrayEnds(int[] nums): swaps the first and last elements of its array parameter. Ex: {10, 20, 30, 40} becomes {40, 20, 30, 10}.
  • removeTen(int[] nums): returns a version of the given array where all the 10's have been removed. The remaining elements should shift left towards the start of the array as needed, and the empty spaces at the end of the array should be set to 0. Ex: {1, 10, 10, 2} yields {1, 2, 0, 0}. You can make a new array and return the new array.

Note that swapArrayEnds() does not need to return the result, as it makes changes to the array referenced by the parameter, which is the same array reference by the argument. On the other hand, removeTen() does not direct make changes to the array, but creates a new array, which requires to be made.

  • Java passes parameter by value, a method cannot change the actual argument. However, a method can make changes to the object that is referenced by the argument.
  • If a method changes the array's contents, the method usually has a void return type.
  • If the method does not change the array's contents, but create a new array, then the method needs to return the newly created array.

public class RemoveTen {
public static void main(String[] args) {
int[] nums = {1, 10, 10, 2};
  
swapArrayEnds(nums);

for(int i = 0; i < nums.length; i++)
System.out.print(nums[i] + " ");

int[] result = removeTen(nums);
  
for(int i = 0; i < result.length; i++)
System.out.print(result[i] + " ");
System.out.println();

for(int i = 0; i < nums.length; i++)
System.out.print(nums[i] + " ");
System.out.println();
}

public static void swapArrayEnds(int[] nums) {
/*FIXME Complete the implementation of the swapArrayEnds method*/
  

}

public static int[] removeTen(int[] nums) {
/*FIXME Complete the implementation of the removeTen method*/
  
}

  
}

In: Computer Science

#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool...

#include <iostream>

#include "lib.hpp"

using namespace std;

int main() {

  

// declare the bool

bool a = true;

bool b= true;

  

//Print the Conjunction function

cout<<"\n\nConjunction Truth Table -"<<endl;

cout<< "\nP\tQ\t(P∧Q)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< conjunction(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< conjunction(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< conjunction(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< conjunction(!a,!b)<<endl;

  

//Print the Disjunction function

cout<<"\n\nDisjunction Truth Table -"<<endl;

cout<< "\nP\tQ\t(PVQ)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< disjunction(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< disjunction(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< disjunction(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< disjunction(!a,!b)<<endl;

  

  

//Print the ExclusiveOr function

cout<<"\n\nExclusiveOr Truth Table -"<<endl;

cout<< "\nP\tQ\t(P⊕Q)" <<endl;

cout<< a <<"\t"<< b <<"\t"<< exclusiveOr(a,b) <<endl;

cout<< a <<"\t"<< !b <<"\t"<< exclusiveOr(a,!b) <<endl;

cout<< !a <<"\t"<< b <<"\t"<< exclusiveOr(!a,b) <<endl;

cout<< !a <<"\t"<< !b <<"\t"<< exclusiveOr(!a,!b)<<endl;

  

  

//Print the Negation function

cout<<"\n\nNegation Truth Table -"<<endl;

cout<< "\nP\t~P" <<endl;

cout<< !a <<"\t" << negation(!a)<<endl;

cout<< a <<"\t" << negation(a) <<endl;

How can u do this code Using the enum keyword or a C++ class? To create a new type Boolean with the two values F and T defined.

In: Computer Science

Ask the user for a filename. In binary format, read all the integers in that file....

Ask the user for a filename. In binary format, read all the integers in that file. Show the number of integers you read in, along with the maximum and minimum integer found. Language is Java.

/////////////input/////////

n1.dat

////////// output//////////

Enter a filename\n
Found 50 integers.\n
Max: 9944\n
Min: 74\n

In: Computer Science

Problem 1: Let’s start by practicing using logical operators and being careful about the order of...

Problem 1: Let’s start by practicing using logical operators and being careful about the order of execution when we use multiple of them in the same expression.

Recall that Boolean expressions use conditional operators to implement basic logic. If all three operators appear in the same expression, Java will evaluate ! first, then &&, and finally ||. If there are multiples of the same operator, they are evaluated from left to right. Relational operators (like <, ==, etc) are evaluated before && and ||, so there is generally no need for parentheses.

Show your work, step-by-step, as you evaluate the following expression in the same order that Java would evaluate this expression:

! (a > c) && b > c

  • What if values of a,b,c are respectively 1,2,3? Result of expression is......

  • What if values of a,b,c are respectively 3,2,1? Result of expression is......

  • What if values of a,b,c are all equal to 3? Result of expression is......

Problem 2: In Java, && and || are short circuit operators, meaning they evaluate only what is necessary.

If the expression p is more likely to be true than the expression q, which one should you place

on the left of each operator to avoid doing extra work? Explain why.

a) left of the && expression:

b) left of the || expression:

Problem 3: What is the result of the following expressions? Do it by hand first, then check yourself by writing it as a code in JAVA.

a) 1 + 0 > 0 && 1 / 0 > 0

b) 1 + 0 > 0 || 1 / 0 > 0

Problem 4: Give four examples of boolean expressions that:

a) uses a, b, and !, and evaluates to false

b) uses b, c, and !, and evaluates to true

c) uses any variables, but evaluates to false

d) uses any variables, but evaluates to true

In: Computer Science

Write a program that reads a line of text input by the user and places each...

Write a program that reads a line of text input by the user and places each word in a TreeSet. Print the elements of the TreeSet to the screen. This will cause the elements to be printed in ascending order.

Using Eclipse for this.

TreeSetUse.java.

In: Computer Science