Questions
I want to compare a string with the previous strings in a forEach loop using javascript....

I want to compare a string with the previous strings in a forEach loop using javascript.

So im accessing data from an API. Im iterating through them using a forEach() loop. I want to compare the current 'title' string from the api with all previous title strings its pulled. The title is located under article.title

fetch(req)

            .then((response) => {

                return response.json();

            })

            .then((data) => {

                console.log(data);

                data.articles.forEach((article) => {

}

If the title matches any other title used already id like to skip the entire iteration.

In: Computer Science

Create a memory diagram for the following C program when the program reaches point 1. void...

Create a memory diagram for the following C program when the program reaches point 1.

void foo (int *a);

int bar(int *x);

int search(int *c);

int main(void)

{

int q, p=10;

q= search(&p);

return 0;

}

void foo(int *a)

{

*a += 2;

//point 1

*f *= 10;

}

int bar(int *x)

{

return 2* *x;

}

int search(int *c)

{

int z= *c + bar(c);

foo(c);

return z;

}

In: Computer Science

CSE/EEE 230 Assignment 4 Fall 2019 Due Sept 30 (11:59PM) In this assignment, you are to...


CSE/EEE 230 Assignment 4
Fall 2019
Due Sept 30 (11:59PM)
In this assignment, you are to complete a MIPS program so it will perform the required tasks. The main function of the code is provided. Do not change the code in the main function. There is a loop in the main function.
You are to complete the program by writing two functions. Pay particular attention to the purpose of each function and how the parameters and return value are to be used.
1. getinput
$a0 - minimum value
$a1 – maximum value
$v0 – integer input in range defined
This function must prompt the user to input an integer and then get the input from the user. The process of printing a prompt and then reading input must be repeated until a value from the minimum to the maximum values is read (inclusive). The input value is then returned in $v0.
2. printsum
The function is to the add the two parameters ($a0 and $a1) and then print the sum.
Sample Input and output:
Enter a number 2  This means that the main will loop 2 times.
Enter a number 7
Enter a number 3
The sum is 10
Enter a number -3
Enter a number -1
Enter a number 25
Enter a number 3
Enter a number 0
Enter a number 6
The sum is 9
General:
• Comment the beginning of your programs with your name and assignment number.
• Comment every instruction.
• Comment each function. Describe which registers are used in the function and how they are used.
Submit your .asm file with the complete program.
Copyright 2019 D.Calliss Arizona State University All rights reserved.
.data
# add any strings at this point as needed
.text
.globl main
main:
addi $a0, $0, 2 # set minimum value as 1
addi $a1, $0, 5 # set maximum value as 15
jal getinput # get a positive number for the loop
addi $s0, $v0, 0 # save input value
repeat:
beq $s0, $0, end # while there are more repeats
addi $a0, $0, 1 # set minimum value as 1
addi $a1, $0, 15 # set maximum value as 15
jal getinput # get a value from 1..15
ori $s1, $v0, 0 # save the result
addi $a0, $0, 3 # set minimum value as 3
addi $a1, $0, 18 # set maximum value as 18
jal getinput # get a value from 4..18
ori $a1, $v0, 0 # set the second parameter for printsum
ori $a0, $s1, 0 # set the first parameter for printsum
jal printsum # call function to print sum of input
addi $s0, $s0, -1 # decrement counter
j repeat # do it again
end: ori $v0, $0, 10 # set command to stop program,
syscall # end program

In: Computer Science

1- The best choice for a data type used to store the grade to be recorded...

1- The best choice for a data type used to store the grade to be recorded at the end of the term for this course would be a(n) ____________. Valid values would be A, B, C, D, or F, no A- or B+ would be permitted, instead a single value will be stored.
2-  
The best choice for a data type used to store the name of the city where you currently live would be in a(n) [a].
3-The best choice for a data type used to store the cost of a pair of shoes would be in a(n) ____________. Hint: For your answer enter the default data type.
4-________ would be stored in x after the following statement (x++), assuming there was a compile time initialization of x defined as int x = 15;
5-If you had three integers defined, x, y and answer, an assignment statement to add the two value together would look like: ____________.
6- The best choice for a data type used to store a counter for the number of courses that you are currently enrolled is a(n) ____________.

In: Computer Science

PLEASE USE THE FLOWORITHM APPLICATION FOR THE ANSWER . I need that not a flowchart .Design...

PLEASE USE THE FLOWORITHM APPLICATION FOR THE ANSWER . I need that not a flowchart .Design the logic for a program that takes in three numbers from the user. Find the largest of the three numbers and output the largest number.

In: Computer Science

['Mary', 'Anna', 'Emma', 'Elizabeth', 'Margaret', 'Minnie', 'Clara', 'Bertha', 'Ida', 'Annie', 'Alice'] Task #2: Using the list...

['Mary', 'Anna', 'Emma', 'Elizabeth', 'Margaret', 'Minnie', 'Clara', 'Bertha', 'Ida', 'Annie', 'Alice']

Task #2: Using the list above create two sets (using the set data structure) (2 points)¶ Write code that will take the values from the list created above and add them to two different sets. You must utilize the set data structure to complete this task.

The set criteria is as follows: set1 - Includes customers with a name length smaller than or equal to 5 characters set2

- Includes customers with a name length greater than or equal to 5 characters

Your code should print the following: {'Clara', 'Alice', 'Emma', 'Mary', 'Anna', 'Ida', 'Annie'}

{'Clara', 'Bertha', 'Margaret', 'Elizabeth', 'Alice', 'Minnie', 'Annie'}

In: Computer Science

You are required to write 4 significant JUnit tests for the Account class outlined below taking...

You are required to write 4 significant JUnit tests for the Account class outlined below taking into account the specifications below. Your code must include 3 negative test cases.

Specifications for the Account class:

  • The constructor takes as arguments the name, ID and the initial balance.
  • The withdrawn method allows any specified amount between $20 and $1000 to be withdrawn but the withdrawn amount cannot exceed the current balance.
  • The withdraw method is expected to throw the AmtTooLow exception if the amount specified is below $20 and the AmtTooHigh exception if the amount exceeds $1000.
  • The withdraw method is expected to throw InsuffientBalance if the amount specified exceeds the balance.
// The outline of Account class. You are not required to complete these 

public class Account {
     …
     public Account(String name, String ID, double amt)
     {   ….

     }
     public double withdraw(double amt) throws AmtTooLow, AmtTooHigh, InsuffientBalance
     {  … 




     }
}

You are required to write the methods with the @Before and @Test annotations only. You should not attempt to run these tests (as the Account class is not complete).

// you need not write the include

public class AccountTest {

// Code to be inserted in the box

In: Computer Science

Windows XP Command Line questions. a) What is the command to display all of the files...

Windows XP Command Line questions.

a) What is the command to display all of the files on the disk in drive A:--do not use the DIR command or the CHKDSK command C:\>

b) Display the contents of the PERSONAL.FIL file located in the root directory of drive A: one screenful at a time

C) Display the contents of the PERSONAL.FIL file located in the root directory of drive A:, one screenful at a time, beginning with the 25th record, on a clear screen using the MORE command.

D)  What is the command to append the contents of the file named STEVEN.FIL to the file called CASES.FIL Both files are on the root directory of drive A:

E) Create a subdirectory under the HOMEWORK directory called CIT-40

F) Copy the file called NAME.NEW from the \TEMP directory into the \HOMEWORK\CIT-40 subdirectory

In: Computer Science

A program at host A sends a UDP datagram carrying 4500 octets1 of data (or payload)...

A program at host A sends a UDP datagram carrying 4500 octets1 of data (or payload) to its counterpart at host C. In between A and C is router B. The MTU between A and B is 1500 octets while between that B and C 1320 octets. Show IP packets and fragments along the path. For each IP packet and fragment, show key header fields like Total Length, Identification, More Flag, and Fragmented Offset

In: Computer Science

2. What are data elements and records? 3. List three control structures in modular design. 4....

2. What are data elements and records?

3. List three control structures in modular design.

4. Draw a picture which shows an example of iteration structure.

5. Provide an example of structured English?

6. Provide an example of decision tables with three conditions.

7. Provide an example of the decision tree.

In: Computer Science

Given two sorted lists, L1 and L2, write an efficient C++ code to compute L1 ∩...

Given two sorted lists, L1 and L2, write an efficient C++ code to compute L1 ∩ L2 using only the basic STL list operations. What is the running time of your algorithm?

In: Computer Science

*In Java please! EXCEPTION HANDLING Concept Summary: 1. Exception   handling   2. Class   design Description Write   a  ...

*In Java please!

EXCEPTION HANDLING
Concept Summary:
1. Exception   handling  
2. Class   design

Description
Write   a   program   that   creates   an   exception   class   called   ManyCharactersException,   designed  
to   be   thrown   when   a   string   is   discovered   that   has   too   many   characters   in   it.
Consider   a   program   that   takes   in   the   last   names   of   users.   The   driver   class   of   the   program
reads the   names   (strings) from   the   user   until   the   user   enters   "DONE".   If   a   name is   entered  
that   has   more   than   20   characters,   throw   the   exception.  
Design   the   program   such   that   it   catches   and   handles   the   exception   if   it   is   thrown.   Handle  
the   exception   by   printing   an   appropriate   message,   and   then   continue   processing   more  
names by   getting   more   inputs   from   the   user. Note:   Your   program   should   exit   only   when   the  
user   enters   "DONE".

SAMPLE OUTPUT:
Enter strings. When finished enter DONE
Short string
You entered: Short string
Medium size string
You entered: Medium size string
Really really long string, someone stop me!
You entered too many characters
DONE
You entered: DONE
Good bye!
RUBRICS:
Design   the   Exception class   (20   points):
Constructing   the   Try…   Catch…   Throw within   the   Driver   class   (40   points)
Constructing   Error   Message   for   the   Exception   class   (10   points)
Constructing   other   error   messages   (20   points)
Loop   and   other   constructs   to   complete   the   program   (10   points)

In: Computer Science

1. You are given Stack.java, an interface class for Stacks. /* Use an array to implement...

1. You are given Stack.java, an interface class for Stacks.
/* Use an array to implement the Stack.java in a class called ArrayStack.java that uses Generics. Write a main function that creates two stacks, one containing 10 Integers and a different one containing 10 Strings, and reverses there contents using a method called reverse that takes as a paramater a Generic array. You will need to implement all the methods of Stack.java as well as create a toString method in ArrayStack.
Requirement: If the stack is full, you need to use double growth to create a new stack and test this in the main. You may want to accomplish this also using a method.

Java Language

In: Computer Science

Flow control is one of the main building blocks that determines how a program should run....

Flow control is one of the main building blocks that determines how a program should run.
Ghana Cocoa Growing Company wishes to compare the impart of two newly acquired
fertilizers on cocoa. They will do this by applying the same quantity of the two fertilizers on
two similar but different cocoa plant under the same conditions (humidity, sunlight, soil
moisture etc.). They will then choose the fertilizer whose crop produces the best harvest
(highest quantity per square feet). As a programmer,
a. Suggest a flow control method that would be used to do the comparison and explain
the reason why you chose it.
b. Write a flow control statement that would do the comparison in “a” above. (5
marks)
c. The Ghana Statistical Services (GSS) is interested in your statement in “b” above but
it is of the view that it is too specific. They want you to modify it by creating a
function that takes four arguments i.e. (the names of the two fertilizer and their
individual yields). The function should return the name of the fertilizer with the
greatest yield.

In: Computer Science

Add two lines of code in main() function to create a variable, goodStudent, whose type is...

Add two lines of code in main() function to create a variable, goodStudent, whose type is Student with name, "John" and age, 21.

public class Student {
   private String name;
   private int age;

   public Student(){
      name = "";
      age= 0;
   }

   public Student(String initName){
      name = initName;
      age = 0;
   }

   public String getName() {
      return name;
   }

   public void setAge(int anAge) {
       age = anAge;
   }

   public static void main (String[] args) {

        // !!!! Your two lines of code come here   !!!
    
   }
}

In: Computer Science