Questions
Need to modify so that it uses a function. We are taking a number and rounding...

Need to modify so that it uses a function. We are taking a number and rounding it to 2 from the decimal.

<!doctype html>
<html>
<head>
   <title> NumberRounder </title>
</head>

<body>
   <h2>Number Rounder</h2>
   <p>
   Enter a number: <input type="text" id="numberBox" size=12 value=3.14159>
   </p>
   <input type="button" value="Round It"
       onclick="number=parseFloat(document.getElementId('numberBox').value);
               rounded=Math.round(number*100)/100;
               document.getElementId('outputDiv').innerHTML=
                   number + ' rounded to one decimal place is ' + rounded;">
  
   <hr>
   <div id="outputDiv"></div>
</body>
</html>

In: Computer Science

Think about some examples of Big data in industry. Try to focus on Vs other than...

Think about some examples of Big data in industry. Try to focus on Vs other than the volume aspect of Big Data. Why do you think these examples qualify as Big Data?

In: Computer Science

The following Java code is set up to ask how many people are attending a meeting...

The following Java code is set up to ask how many people are attending a meeting and checks these user generate responses with replies, using the do while setup. To end the loop you type 0, change this to accept the answer "Y" to continue the loop after every response and "N" to end the loop with every case type. (Y,y,N,n)

Meeting.java
------
import java.util.Scanner;

public class Meeting {
   public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       final int ROOM_CAPACITY = 100;
       int numPeople, diff;
       String name;
       System.out.println("****** Meeting Organizer ******");
      
       System.out.print("Enter your name: ");
       name = input.nextLine();
       System.out.println("Welcome " + name);
       do{
           System.out.print("\nHow many people would attend the meeting? (type 0 to quit): ");
           numPeople = input.nextInt();
           if(numPeople < 0)
               System.out.println("Invalid input!");
           else if(numPeople != 0)
           {
               if(numPeople > ROOM_CAPACITY)
               {
                   diff = numPeople - ROOM_CAPACITY;
                   System.out.println("Sorry! The room can only accommodate " + ROOM_CAPACITY +" people. ");
                   System.out.println(diff + " people have to drop off");
               }
               else if(numPeople < ROOM_CAPACITY)
               {
                   diff = ROOM_CAPACITY - numPeople;
                   System.out.println("The meeting can take place. You may still invite " + diff + " people");
               }
               else
               {
                   System.out.println("The meeting can take place. The room is full");
               }
           }
       }while(numPeople != 0);
       System.out.println("Goodbye!");   }
}

In: Computer Science

7/Draw a flowchart that asks the user to enter an array of random numbers, then sorts...

7/Draw a flowchart that asks the user to enter an array of random numbers, then sorts the numbers (descending order), after that reverses it (the first element will be the last...).

In: Computer Science

How to write code for stack with singly linked list using C? Please show examples for...

How to write code for stack with singly linked list using C?

Please show examples for create, free, isempty, push, top, pop functions.

In: Computer Science

In a computer instruction format, the instruction length is 16 bits and the size of an...

In a computer instruction format, the instruction length is 16 bits and the size of an address field is 4 bits. Is it possible to have: 15 instructions with 3 addresses, 14 instructions with 2 addresses, 31 instructions with one address, and 16 instructions with zero addresses, using this format? Justify your answer.

In: Computer Science

Discuss impact of Big data on databases and database design (Hadoop). Give examples of application.

Discuss impact of Big data on databases and database design (Hadoop). Give examples of application.

In: Computer Science

Consider the following relations: Please answer in the form of symbol. Thank You Student (ssn, name,...

Consider the following relations: Please answer in the form of symbol. Thank You

Student (ssn, name, address, major)

Course(code, title)

Registered(ssn,code)

  1. List the titles of all courses
  2. List the information of the students majoring in ‘CS’
  3. List the codes of courses for which at least one student is registered (registered courses
  4. List the titles of registered courses
  5. List the codes of courses for which no student is registered

In: Computer Science

Please complete the following functions in "queue.c" using C. This must use the dynamic array provided...

Please complete the following functions in "queue.c" using C. This must use the dynamic array provided in "dynarray.c"

--------------------------------------------------------------------------------------------

//queue.c

#include <stdlib.h>

#include "queue.h"
#include "dynarray.h"

/*
* This is the structure that will be used to represent a queue. This
* structure specifically contains a single field representing a dynamic array
* that should be used as the underlying data storage for the queue.
*
* You should not modify this structure.
*/
struct queue {
struct dynarray* array;
};

/*
* This function should allocate and initialize a new, empty queue and return
* a pointer to it.
*/
struct queue* queue_create() {
return NULL;
}

/*
* This function should free the memory associated with a queue. While this
* function should up all memory used in the queue itself, it should not free
* any memory allocated to the pointer values stored in the queue. This is the
* responsibility of the caller.
*
* Params:
* queue - the queue to be destroyed. May not be NULL.
*/
void queue_free(struct queue* queue) {
return;
}

/*
* This function should indicate whether a given queue is currently empty.
* Specifically, it should return 1 if the specified queue is empty (i.e.
* contains no elements) and 0 otherwise.
*
* Params:
* queue - the queue whose emptiness is being questioned. May not be NULL.
*/
int queue_isempty(struct queue* queue) {
return 1;
}

/*
* This function should enqueue a new value into a given queue. The value to
* be enqueued is specified as a void pointer. This function must have O(1)
* average runtime complexity.
*
* Params:
* queue - the queue into which a value is to be enqueued. May not be NULL.
* val - the value to be enqueued. Note that this parameter has type void*,
* which means that a pointer of any type can be passed.
*/
void queue_enqueue(struct queue* queue, void* val) {
return;
}

/*
* This function should return the value stored at the front of a given queue
* *without* removing that value. This function must have O(1) average runtime
* complexity.
*
* Params:
* queue - the queue from which to query the front value. May not be NULL.
*/
void* queue_front(struct queue* queue) {
return NULL;
}

/*
* This function should dequeue a value from a given queue and return the
* dequeued value. This function must have O(1) average runtime complexity.
*
* Params:
* queue - the queue from which a value is to be dequeued. May not be NULL.
*
* Return:
* This function should return the value that was dequeued.
*/
void* queue_dequeue(struct queue* queue) {
return NULL;
}

------------------------------------------------

// dynarray.c

#include <stdlib.h>
#include <assert.h>

#include "dynarray.h"

/*
* This structure is used to represent a single dynamic array.
*/
struct dynarray {
void** data;
int size;
int capacity;
};

#define DYNARRAY_INIT_CAPACITY 4

/*
* This function allocates and initializes a new, empty dynamic array and
* returns a pointer to it.
*/
struct dynarray* dynarray_create() {
struct dynarray* da = malloc(sizeof(struct dynarray));
assert(da);

da->data = malloc(DYNARRAY_INIT_CAPACITY * sizeof(void*));
assert(da->data);
da->size = 0;
da->capacity = DYNARRAY_INIT_CAPACITY;

return da;
}

/*
* This function frees the memory associated with a dynamic array. Freeing
* any memory associated with values stored in the array is the responsibility
* of the caller.
*
* Params:
* da - the dynamic array to be destroyed. May not be NULL.
*/
void dynarray_free(struct dynarray* da) {
assert(da);
free(da->data);
free(da);
}

/*
* This function returns the size of a given dynamic array (i.e. the number of
* elements stored in it, not the capacity).
*/
int dynarray_size(struct dynarray* da) {
assert(da);
return da->size;
}


/*
* Auxilliary function to perform a resize on a dynamic array's underlying
* storage array.
*/
void _dynarray_resize(struct dynarray* da, int new_capacity) {
assert(new_capacity > da->size);

/*
* Allocate space for the new array.
*/
void** new_data = malloc(new_capacity * sizeof(void*));
assert(new_data);

/*
* Copy data from the old array to the new one.
*/
for (int i = 0; i < da->size; i++) {
new_data[i] = da->data[i];
}

/*
* Put the new array into the dynarray struct.
*/
free(da->data);
da->data = new_data;
da->capacity = new_capacity;
}

/*
* This function inserts a new value to a given dynamic array. The new element
* is always inserted at the *end* of the array.
*
* Params:
* da - the dynamic array into which to insert an element. May not be NULL.
* val - the value to be inserted. Note that this parameter has type void*,
* which means that a pointer of any type can be passed.
*/
void dynarray_insert(struct dynarray* da, void* val) {
assert(da);

/*
* Make sure we have enough space for the new element. Resize if needed.
*/
if (da->size == da->capacity) {
_dynarray_resize(da, 2 * da->capacity);
}

/*
* Put the new element at the end of the array.
*/
da->data[da->size] = val;
da->size++;
}

/*
* This function removes an element at a specified index from a dynamic array.
* All existing elements following the specified index are moved forward to
* fill in the gap left by the removed element.
*
* Params:
* da - the dynamic array from which to remove an element. May not be NULL.
* idx - the index of the element to be removed. The value of `idx` must be
* between 0 (inclusive) and n (exclusive), where n is the number of
* elements stored in the array.
*/
void dynarray_remove(struct dynarray* da, int idx) {
assert(da);
assert(idx < da->size && idx >= 0);

/*
* Move all elements behind the one being removed forward one index,
* overwriting the element to be removed in the process.
*/
for (int i = idx; i < da->size - 1; i++) {
da->data[i] = da->data[i+1];
}

da->size--;
}

/*
* This function returns the value of an existing element in a dynamic array.
*
* Params:
* da - the dynamic array from which to get a value. May not be NULL.
* idx - the index of the element whose value should be returned. The value
* of `idx` must be between 0 (inclusive) and n (exclusive), where n is the
* number of elements stored in the array.
*/
void* dynarray_get(struct dynarray* da, int idx) {
assert(da);
assert(idx < da->size && idx >= 0);

return da->data[idx];
}

/*
* This function updates (i.e. overwrites) the value of an existing element in
* a dynamic array.
*
* Params:
* da - the dynamic array in which to set a value. May not be NULL.
* idx - the index of the element whose value should be updated. The value
* of `idx` must be between 0 (inclusive) and n (exclusive), where n is the
* number of elements stored in the array.
* val - the new value to be set. Note that this parameter has type void*,
* which means that a pointer of any type can be passed.
*/
void dynarray_set(struct dynarray* da, int idx, void* val) {
assert(da);
assert(idx < da->size && idx >= 0);

da->data[idx] = val;
}

In: Computer Science

subject software project management a)Who controls the code inspection meeting? What are the different metrics collected...

subject software project management

a)Who controls the code inspection meeting? What are the different metrics collected in the inspection meeting?

b)Can reviews and inspections tasks replace/eliminate the testing tasks? Explain.

In: Computer Science

Wireless Sensor Networks/Internet of Things Topic What are the main issues that affect localization?

Wireless Sensor Networks/Internet of Things Topic

What are the main issues that affect localization?

In: Computer Science

What will you review and assess within the LAN-to-WAN Domain as part of this security assessment?

What will you review and assess within the LAN-to-WAN Domain as part of this security assessment?

In: Computer Science

What is the goal of security audits and the importance of establishing best practices within and...

What is the goal of security audits and the importance of establishing best practices within and organization?

NEED 300 WORDS

In: Computer Science

Business Intelligence (BI) and Analytics. Be able to explain the goals and advantages of Business Intelligence...

Business Intelligence (BI) and Analytics.

Be able to explain the goals and advantages of Business Intelligence (BI) and Analytics.

Expert systems & Artificial Intelligence

Be able to describe how an expert systems function

Include as much information on expert systems and AI

--------------------------------------------

Please type it in words so I can understand it and copy it.

Thank you so much!!

----------------------------------------------

In: Computer Science

You must write the correct code for all member methods so that queue functionality can be...

You must write the correct code for all member methods so that queue functionality can be obtained. Changes to the class definition, instance variables, and signatures of the membership method are not allowed. This class has no main method.

package javaclass;

/**

* A queue structure of Movie objects. Only the Movie values contained

* in the queue are visible through the standard queue methods. The Movie

* values are stored in a DoubleLink object provided in class as attribute.

*

*

*

* @version 2013-07-04

*

* @param Movie

* this data structure value type.

*/

public class DoubleQueue {

// First node of the queue

private DoubleLink values = null;

/**

   * Combines the contents of the left and right Queues into the current

   * Queue. Moves nodes only - does not move value or call the high-level

   * methods insert or remove. left and right Queues are empty when done.

   * Nodes are moved alternately from left and right to this Queue.

   *

   * @param source1

   * The front Queue to extract nodes from.

   * @param source2

   * The second Queue to extract nodes from.

   */

public void combine(final DoubleQueue source1,

final DoubleQueue source2) {

// your code here

}

/**

   * Adds value to the rear of the queue.

   *

   * @param value

   * The value to added to the rear of the queue.

   */

public void insert(final Movie value) {

// your code here

}

/**

   * Returns the front value of the queue and removes that value from the

   * queue. The next node in the queue becomes the new front node.

   *

   * @return The value at the front of the queue.

   */

public Movie remove() {

//your code here

return null;//you must change this statement as per your requirement

}

/**

   * Returns the value at the front. Must be copy safe

   *

   * @return the value at the front.

   */

public Movie peekFront() {

// your code here

return null;//you must change this statement as per your requirement

}

/**

   * Returns the value at the rear. Must be copy safe.

   *

   * @return the value at the rear.

   */

public Movie peekRear() {

// your code here

return null;//you must change this statement as per your requirement

}

/**

   * Returns all the data in the queue in the form of an array.

   *

   * @return The array of Movie elements. Must be copy safe

   */

public final Movie [] toArray() {

//your code here

return null;//you must change this statement as per your requirement

}

}

Double link class

package javaclass;

/**

* The class for doubly-linked data structures. Provides attributes

* and implementations for getLength, isEmpty, and toArray methods.

* The head attribute is the first node in any doubly-linked list and

* last is the last node.

*

* @author

* @version 2017-11-01

*

*/

public class DoubleLink {

// First node of double linked list

private DoubleNode head = null;

// Number of elements currently stored in linked list

private int length = 0;

// Last node of double linked list.

private DoubleNode last = null;

/**

   * Adds a new Movie element to the list at the head position

   * before the previous head, if any. Increments the length of the List.

*

   * @param value

   * The value to be added at the head of the list.

*

   * @return true if node is added successfully, else false.

   */

public final boolean addNode(final Movie value) {

//your code here

return false;//you must change this statement as per your requirement

}

/**

   * Removes the value at the front of this List.

   *

   * @return The value at the front of this List.

   */

public Movie removeFront() {

// your code here

return null;//you must change this statement as per your requirement

}

/**

   * Returns the head element in the linked structure. Must be copy safe.

   *

   * @return the head node.

   */

public final DoubleNode getHead() {

//your code here

return null;//you must change this statement as per your requirement

}

/**

   * Returns the current number of elements in the linked structure.

   *

   * @return the value of length.

   */

public final int getLength() {

//your code here

return -1;//you must change this statement as per your requirement

}

/**

   * Returns the last node in the linked structure. Must be copy safe.

   *

   * @return the last node.

   */

public final DoubleNode getLast() {

//your code here

return null;//you must change this statement as per your requirement

}

/**

   * Determines whether the double linked list is empty or not.

   *

   * @return true if list is empty, false otherwise.

   */

public final boolean isEmpty() {

//your code here

return true;//you must change this statement as per your requirement

}

/**

   * Returns all the data in the list in the form of an array.

   *

   * @return The array of Movie elements. Must be copy safe

   */

public final Movie [] toArray() {

//your code here

return null;//you must change this statement as per your requirement

}

}

In: Computer Science