Questions
Write the following Java code into Pseudocode import java.util.*; public class Main { // Searching module...

Write the following Java code into Pseudocode

import java.util.*;
public class Main
{ // Searching module
public static void score_search(int s,int score[])
{ // Initialise flag as 0
int flag=0;
// Looping till the end of the array
for(int j=0;j<10;j++)
{ // If the element is found in the array
if(s==score[j])
{ // Update flag to 1
flag=1;
}
}
// In case flag is 1 element is found
if(flag==1)
{
System.out.println("golf score found");
}
// // In case flag is 0 element is not found
else
{
System.out.println("golf score not found");
}
// Modification module
public static int[] modify(int score[],int t)
{ // Initialise new score array
int newscore[]=new int[11];
// Copying the scores to the new array
for(int k=0;k<10;k++)
{
newscore[k]=score[k];
}
// storing the new score at the last position
newscore[10]=t;
// return the new score array
return newscore;
}
// main function
   public static void main(String[] args) {
   // Declaring the variables
   int swap,i,a,b,search,temp;
   // Instantiate object of Scanner class
   Scanner sc=new Scanner(System.in);
   // Declaring the golf score array
   int score[]=new int[10];
   System.out.print("Enter the golf scores:");
   // Asking user to enter the golf scores
   for(i=0;i<10;i++)
   {
   score[i]=sc.nextInt();
   }
   // Sorting the golf scores in ascending order
// Looping til the end of the array
   for(a=0;a<10;a++)
   { // Looping from second element till the end
   for(b=a+1;b<10;b++)
   { // In case first score is greater then second score
   // Swap the golf scores
   if(score[b]<score[a])
   {
   swap=score[a];
   score[a]=score[b];
   score[b]=swap;
   }
   }
   }
       System.out.print("Sorted golf scores:");
       // Printing the sorted golf scores
       for(i=0;i<10;i++)
       {
       System.out.print(score[i]+" ");
       }
       System.out.println("");
       System.out.println("Enter the score to be searched:");
       // Asking user to enter the golf score to be searched
       search=sc.nextInt();
       // Calling the Searching module
       score_search(search,score);
       System.out.println("Enter the new score:");
       // Asking user to enter the golf score to be added
       temp=sc.nextInt();
       // Printing and calling the Modification module
       System.out.println("Modified golf score:"+Arrays.toString(modify(score,temp)));
   }
}

In: Computer Science

What is the CIDR for Each ?? Please Explain. Demilitarized Zone (DMZ) Network Segment (10.252.1.x) Internal...

What is the CIDR for Each ?? Please Explain.

Demilitarized Zone (DMZ) Network Segment (10.252.1.x)

Internal Servers & Storage Network Segment (10.252.5.x)

Marketing Network Segment (10.252.7.x)

Financial Advisors Network Segment (10.252.2.x)

Human Resources (HR) Network Segment (10.252.9.x)

Information Technology (IT) Network Segment (10.252.3.x)

Shipping Network Segment (10.252.8.x)

Receiving Network Segment (10.252.6.x)

Operations (OPS) Network Segment (10.252.4.x)

In: Computer Science

Please write the answer on a computer not on a paper I'm a little confused as...

Please write the answer on a computer not on a paper

I'm a little confused as to what exactly I'm researching and writing about. If someone could break it down and give me a few minor examples so I can structure the essay around it I would really appreciate it:

(Intel 80x86, ARM, MIPS R4000 )Write a two page report on the similarities and differences are of these architectures. Include in your report what you find interesting about the architectures you researched

In: Computer Science

7. What are the applications of an Embedded and Real Time Systems. 8. Analyze in detail...

7. What are the applications of an Embedded and Real Time Systems.

8. Analyze in detail about the challenges in Embedded and Real-Time systems design.

9. What are the parameters to be considered while designing an Embedded System Process?

10. Why microprocessor/microcontroller is used in Embedded system.

In: Computer Science

Write a C/C++ program that reads a 8-bit value from the screen, calculate the CRC-16 result,...

Write a C/C++ program that reads a 8-bit value from the screen, calculate the CRC-16 result, and print it on the screen.
The input can be any 8-bit value in the hexadecimal form(with or without Ox), e.g., Al for 10100001
The output can be either in hexadecimal or binary form.
The initialization bits are all ones.
The result XoR bits are all ones
The code should be well commented
Do not use existing packages

In: Computer Science

Imagine you have a rotary combination lock with many dials. Each dial has the digits 0...

Imagine you have a rotary combination lock with many dials. Each dial has the digits 0 - 9. At any point in time, one digit from each dial is visible.

Each dial can be rotated up or down. For some dial, if a 4 is currently visible then rotating the dial up would make 5 visible; rotating the dial down would make 3 visible. When 0 is the visible digit then rotating down would make 9 visible. Similarly, when 9 is visible then rotating up would make 0 visible.

We have devised a robotic finger to manipulate such combination systems. The robotic finger takes as input a String that indicates the operations to be performed. An L moves the finger one dial to the left, an R moves the finger one dial to the right, and a + rotates the dial that the finger is at up and a - rotates the dial that the finger is at down.

The robotic finger always starts at the leftmost dial.

Task 1: Basic Operations

Valid Sequence

Given a String that consists of (only) the characters L, R, + and -, determine if this String represents a valid sequence of operations.

A valid sequence of operations would not move the finger to the left of the leftmost dial or to the right of the rightmost dial.

public boolean validOperation(String ops, int numDials) {

Rotations

Given a sequence of operations in String form, as well as an initial arrangement of the dials, determine the digits that will be visible after the operations have been performed.

public int[] rotate(int[] initialState, String ops) {

Task 2: Finding Rotation Sequences

Given an initial state of the dials and a final state, return a String that represents a sequence of operations of shortest length that transforms the initial state to the final state.

public String getRotationSequence(int[] initialState, int[] newState) {

TEST CASE

@Test
public void testValidOp1() {
    RoboticFinger rf = new RoboticFinger();
    assertTrue(rf.validOperation("R++L++-RRR", 4));
}

@Test
public void testValidOp2() {
    RoboticFinger rf = new RoboticFinger();
    assertTrue(!rf.validOperation("R++L++-RRR", 3));
}

@Test
public void testValidOp3() {
    RoboticFinger rf = new RoboticFinger();
    assertTrue(!rf.validOperation("L-+R++RR", 10));
}

@Test
public void testValidOp4() {
    RoboticFinger rf = new RoboticFinger();
    assertTrue(!rf.validOperation("RRR+-R+R+LL", 4));
}

@Test
public void testValidOp5() {
    RoboticFinger rf = new RoboticFinger();
    assertTrue(rf.validOperation("RRR+-R+R+LL", 6));
}

@Test
public void testRotate1() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {1, 2, 4, 4, 5};
    String ops = "R++R-";
    int[] expectedState = {1, 4, 3, 4, 5};
    assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}

@Test
public void testRotate2() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {1, 2, 4, 4, 5};
    String ops = "R++R-R-L++";
    int[] expectedState = {1, 4, 5, 3, 5};
    assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}

@Test
public void testRotate3() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {7, 0, 2, 9, 1, 5, 6};
    String ops = "R-R++R+++R+RR--";
    int[] expectedState = {7, 9, 4, 2, 2, 5, 4};
    assertArrayEquals(expectedState, rf.rotate(initialState, ops));
}
@Test
public void testGetRotationSequence1() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {1, 2, 4, 4, 4, 7};
    int[] finalState = {2, 7, 3, 4, 8, 9};
    int expectedLength = "+R+++++R-RR++++R++".length();
    String ops = rf.getRotationSequence(initialState, finalState);
    assertArrayEquals(finalState, rf.rotate(initialState, ops));
    assertEquals(expectedLength, ops.length());
}

@Test
public void testGetRotationSequence2() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {9, 9, 9, 9, 9, 9, 1};
    int[] finalState = {2, 7, 3, 4, 8, 9, 2};
    int expectedLength = 22;
    String ops = rf.getRotationSequence(initialState, finalState);
    assertArrayEquals(finalState, rf.rotate(initialState, ops));
    assertEquals(expectedLength, ops.length());
}

@Test
public void testGetRotationSequence3() {
    RoboticFinger rf = new RoboticFinger();
    int[] initialState = {5};
    int[] finalState = {7};
    int expectedLength = 2;
    String ops = rf.getRotationSequence(initialState, finalState);
    assertArrayEquals(finalState, rf.rotate(initialState, ops));
    assertEquals(expectedLength, ops.length());
}

In: Computer Science

C++ programming Create an application for generating lottery tickets of random numbers. Each lottery ticket has...

C++ programming

Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range. For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100. The values are selected at random.

The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user. The count of numbers must be less than the upper range. The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket. Any number of lottery tickets may be generated.

The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example, lotto(51, 6) will select 6 numbers at random between 1 and 51 (inclusive.) The function should return a vector of unique integer values in sorted order.

The displayTicket function accepts a vector of integers and displays the vector.

Hints: Although the standard library defines a rand() function for generating random numbers, the function may produce duplicate numbers and hence, is not suitable for this application. To ensure that unique values are generated, create a vector that contains all possible values (1 through the given upper range) and then shuffle these values using the random_shuffle() function. This will result in a vector of numbers between 1 and the upper range in random order. From this vector, select the required number of values from the beginning of the vector, adding these values to the result vector. Lastly, use the sort() function to sort the result vector.

The random_shuffle() and sort() functions require two parameters that specify the beginning and ending elements on which to operate. To specify the beginning and ending of the vector, the begin() and end() methods of the vector class can be used. For example, when the vector allNumbers contains all the values between 1 and 51, the values within the vector can be rearranged (shuffled) using: random_shuffle(allNumbers.begin(),allNumbers.end());

In: Computer Science

Write a C++ program that reads numbers from the user until the user enters a Sentinel....

Write a C++ program that reads numbers from the user until the user enters a Sentinel. Use a Sentinel of -999. Ignore all negative numbers from the user input (other than the sentinel).

Do the following:

1. Output the sum of all even numbers

2. Output the sum of all odd numbers

3. Output the count of all even numbers

4. Output the count of all odd numbers

You must use alternation ('if' statements), loops and simple calculations to do this. You must not use any arrays or vectors for this program.

In: Computer Science

In Exercises 1-9, prove each of the given statements from the given premises. You may use...

In Exercises 1-9, prove each of the given statements from the given premises. You may use any of the following statements, with all occurrences of a letter replaced by a particular statement, as premises.

I) (P → S) ↔ ( ¬S → ¬P)

II) ¬Q ∧ (S ∨ Q) → S

III) ¬¬R ↔ R

IV) P → P ∨ R

In Exercises 1-7 use direct proofs.

2.) Premises: ¬S, P → S, ¬P ∨ Q → W

Prove: W


this question is COMPLETE. it says “2.)” at the bottom, meaning it is question #2 in my textbook.

In: Computer Science

Write Arduino program to implement wiring three momentary switches to the Arduino board

Write Arduino program to implement wiring three momentary switches to the Arduino board

In: Computer Science

The move for many businesses is to the cloud. Based on your reading, why do think...

The move for many businesses is to the cloud. Based on your reading, why do think this is the trend? What do you suppose some of the impacts of the repeal of Net Neutrality may have on this trend?

please give a one page answer description and also provide references

In: Computer Science

2) Write an algorithm to compute the area of circles. Your algorithm should prompt the user...

2) Write an algorithm to compute the area of circles. Your algorithm should prompt the user to take the number of circles and their radius values. Then it should compute the areas of each circle. Finally, your algorithm will print both radius and area of all circles into the output. [N.B. you need to use iterative statement for solving the problem. Consider Pi = 3.14159] Input: Area of how many Circles you want to compute? 3 Key in radius values: 2.5 3.12 2.16 Output: Radius is 2.5 and the Area is 19.63 Radius is 3.12 and the Area is 30.76 Radius is 2.16 and the Area is 14.65

C program

In: Computer Science

Software Engineering Subject 1.  Discuss the four phases of the Rational Unified Process (RUP) and their relationship...

Software Engineering Subject

1.  Discuss the four phases of the Rational Unified Process (RUP) and their relationship to the development activities such as requirements analysis, design, and testing.

In: Computer Science

Your task is to count the frequency of words in a text file, and return the...

Your task is to count the frequency of words in a text file, and return the most frequent word with its count. (Must use the code below without changing algorithms)

For example, given the following text:

there are two ways of constructing a software design one way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.

Based on the example your program should printout the following along with the milliseconds to finish the computing:
The most frequent word is "there" with 3 occurrences.

The code is below, it doesn't seem to printout what word is the most frequent and how many occurrences of it there are.

import java.io.File;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.AbstractMap;
import java.util.LinkedList;

public class WordCountLinkedList254{

    public static Entry count_ARRAY(String[] tokens) {

        int CAPACITY = 10000;
        String[] words = new String[CAPACITY];
        int[] counts = new int[CAPACITY];

        for (int j = 0; j < tokens.length; j++) {
            String token = tokens[j];
            for (int i = 0; i < CAPACITY; i++) {
                if (words[i] == null) {
                    words[i] = token;
                    counts[i] = 1;
                    break;
                } else if (words[i].equals(token))
                    counts[i] = counts[i] + 1;
            }
        }
        int maxCount = 0;
        String maxWord = "";
        for (int i = 0; i < CAPACITY & words[i] != null; i++) {
            if (counts[i] > maxCount) {
                maxWord = words[i];
                maxCount = counts[i];
            }
        }
        return new AbstractMap.SimpleEntry < String, Integer > (maxWord, maxCount);
    }
  
   public static Entry count_LINKED_LIST(String[] tokens) {
        LinkedList> list = new LinkedList> ();
        for (int j = 0; j < tokens.length; j++) {
            String word = tokens[j];
            boolean found = false;

            /* for (int i = 0; i < list.size(); i++) {
            Entry e = list.get(i);
            if (word.equals(e.getKey())) {
            e.setValue(e.getValue() + 1);
            list.set(i, e);
            found = true;
            break;
               }
            }*/

            int i = 0;
            for (Entry e: list) {
                if (word.equals(e.getKey())) {
                    e.setValue(e.getValue() + 1);
                    list.set(i, e);
                    i++;
                    found = true;
                    break;
                }
            }

            if (!found)
                list.add(new AbstractMap.SimpleEntry (word, 1));
        }
        int maxCount = 0;
        String maxWord = "";
        for (int i = 0; i < list.size(); i++) {
            int count = list.get(i).getValue();
            if (count > maxCount) {
                maxWord = list.get(i).getKey();
                maxCount = count;
            }
        }
        return new AbstractMap.SimpleEntry < String, Integer > (maxWord, maxCount);
    }
  
    static String[] readText(String PATH) throws Exception {
        Scanner doc = new Scanner(new File(PATH)).useDelimiter("[^a-zA-Z]+");
        int length = 0;
        while (doc.hasNext()) {
            doc.next();
            length++;
        }
      
        String[] tokens = new String[length];
        Scanner s = new Scanner(new File(PATH)).useDelimiter("[^a-zA-Z]+");
        length = 0;
        while (s.hasNext()) {
            tokens[length] = s.next().toLowerCase();
            length++;
        }
        doc.close();
      
        return tokens;
    }
  
    public static void main(String[] args) throws Exception {
      
        String PATH = "/Users/jianguolu/Dropbox/254/code/dblp1k.txt ";
        String[] tokens = readText(PATH);
        long startTime = System.currentTimeMillis();
        Entry entry = count_LINKED_LIST(tokens);
        long endTime = System.currentTimeMillis();
        String time = String.format("%12d", endTime - startTime);
        System.out.println("time\t" + time + "\t" + entry.getKey() + ":" + entry.getValue());
      
        tokens = readText(PATH);
        startTime = System.currentTimeMillis();
        entry = count_ARRAY(tokens);
        endTime = System.currentTimeMillis();
        time = String.format("%12d", endTime - startTime);
        System.out.println("time\t" + time + "\t" + entry.getKey() + ":" + entry.getValue());
    }
}

In: Computer Science

Topic: Artificial intelligence ( Artificial intelligence in society) Assignment: You are expected to submit a typed,...

Topic: Artificial intelligence ( Artificial intelligence in society)

Assignment: You are expected to submit a typed, formal, full-sentence outline for your presentation. Consult notes from our class discussion on organization and outlining and the appropriate sections of the textbook for more information. Please also see the Informative Speech Formal Outline Example posted in Canvas in the section of Supplemental Materials. You must submit a typed, formal, full-sentence outline for your Informative speech in order for your Informative Speech to be reviewed and graded by the instructor.

An outline is not a manuscript but it should include sufficient detail so the reader can have more than a general idea of your presentation content. Your outline is required to include the Roman Numeral level and capital letter level of subpoint structure. You may also include the Arabic Numeral level of subpointing as well. Remember the "rule of 2" in your outline development. Your outline should not contain all ideas you present in your speech--it is a skeleton of the ideas--I assume you will say more than what appears on the outline. Accordingly, the outline should not contain so much content that it is essentially a manuscript of your speech.  

Please cite your sources on the outline where they are used in the speech. Parenthetically reference the source on your outline following the cited ideas. Just including the source name is fine, provided there is no other source with the same name.

Attach a “References” page using APA format to your formal outline. Remember that Reference page entries are always listed alphabetically using the first character of the citation. Purdue OWL is an excellent resource to help you prepare accurate Reference pages. Use 11 or 12 point font in Times New Roman or Arial.

The Formal Outline is due no later than the date/time posted in Canvas and on the Tentative Class Schedule for the Informative Presentation and Outline. Please upload the Formal Outline to the appropriate assignment in Canvas.

Please also review the supplemental course information regarding plagiarism and be sure to avoid plagiarism anytime in this class and on researched assignments.

In: Computer Science