Questions
Write a method that displays every other element of an array. Write a program that generates...

Write a method that displays every other element of an array.

Write a program that generates 100 random integers between 0 and 9 and displays the count for each number. (Hint: Use an array of ten integers, say counts, to store the counts for the number of 0s, 1s, . . . , 9s.)

Write two overloaded methods that return the average of an array with the following headers:   

  public static int average(int[] intArray)     

  public static double average(double[] dArray)

Also, write a test program that prompts the user to enter ten double values, invokes the correct method, and displays the average value.

Given this array, write the code to find the smallest value in it:

  int[] myList = new myList[n];

In: Computer Science

UNIX 1. Compile and run shell0.c file 2. Design and implement shell1.c program to handle "exit"...

UNIX

1. Compile and run shell0.c file

2. Design and implement shell1.c program to handle "exit" command to terminate the program.
That is, if the user input-string is "exit", then the program terminates.

3.Design and Implement shell2.c to implement a signal handler to handle ctrl+C (SIGINT) as listed below

            void sig_int(int signo) { printf("\nCaught SIGINT!\n"); }

Here is shell0.c file

shell0.c

/*
 *  shell0.c 
 *     running in loop to read input string (command) to be processed
 *     To exit, type EOF (ctlr+D) or ctlr+C 
 */
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>

char *getinput(char *buffer, size_t buflen) 
{
        printf("$$ ");
        return fgets(buffer, buflen, stdin);
}

int main(int argc, char **argv) 
{
        char buf[1024];
        pid_t pid;
        int status;

        while (getinput(buf, sizeof(buf))) {
                buf[strlen(buf) - 1] = '\0';

                if((pid=fork()) == -1) {
                        fprintf(stderr, "shell: can't fork: %s\n",
                                        strerror(errno));
                        continue;
                } else if (pid == 0) {
                        /* child */
                        execlp(buf, buf, (char *)0);
                        fprintf(stderr, "shell: couldn't exec %s: %s\n", buf,
                                        strerror(errno));
                        exit(EX_DATAERR);
                }

                if ((pid=waitpid(pid, &status, 0)) < 0)
                        fprintf(stderr, "shell: waitpid error: %s\n",
                                        strerror(errno));
        }
        exit(EX_OK);
}

In: Computer Science

Create a set of use case documents and use case diagrams for a university library borrowing...

  • Create a set of use case documents and use case diagrams for a university library borrowing system (Do not worry about catalogue searching etc.)
  • The system will record who has borrowed what books. Before someone can borrow a book, he or she must show a valid ID card that is checked to ensure that it is still valid against the student database maintained by the registrar's office.
  • The system must also check to ensure that the borrower does not have any overdue books or unpaid fines before he or she can borrow another book.

In: Computer Science

Java Q1: Create a class named Triangle, the class must contain: Private data fields base and...

Java

Q1: Create a class named Triangle, the class must contain:

  • Private data fields base and height with setter and getter methods.
  • A constructor that sets the values of base and height.
  • A method named toString() that prints the values of base and height.
  • A method named area() that calculates and prints the area of a triangle.

  • Draw the UML diagram for the class.
  • Implement the class.

Q2: Write a Java program that creates a two-dimensional array of type integer of size x by y (x and y must be entered by the user). The program must fill the array with random numbers from 1 to 100. The program must prompt the user to enter a search key between 1 and 100. Then, the program must check whether the search key is available in the array and print its location.

Here is a sample run:

Enter the number of rows: 5

Enter the number of columns: 5

Enter a search key between 1-100: 27

The key you entered is available at row 3, column 2.

Here is another sample run:

Enter the number of rows: 5

Enter the number of columns: 5

Enter a search key between 1-100: 33

The key you entered is not available in the array.

In: Computer Science

You are on a diet and you are writing a javascript program that determines whether or...

You are on a diet and you are writing a javascript program that determines whether or not you can treat yourself to an ice cream. Your program takes as input:
1. Number of calories you have taken so far that day.
2. Number of calories you are expecting to take later on that day (excluding the potential
ice cream)
3. Number of calories you have burnt (or are expecting to burn) with exercise that day. 4. What is your goal of number of calories taken for a day.
5. The number of calories in the ice cream that you're thinking of eating!
and outputs whether or not you can take that ice cream

In: Computer Science

Design a multiplexed communication system that can be used for 1 of 4 senders (sources) to...

Design a multiplexed communication system that can be used for 1 of 4 senders (sources) to send 3 bits to 1 of 2 receivers (destinations) using a 3-bit 4×1 multiplexer and a 2-bit 1×2 demultiplexer. Assume that the most significant of the 3 bits denotes the header containing the destination ID and that the 2 less significant bits denote the message. Represent both the 3-bit 4×1 multiplexer and a 2-bit 1×2 demultiplexer using block diagrams with all inputs and outputs labeled. Show which outputs of the multiplexer connect to which inputs of the demultiplexer!

In: Computer Science

Draw an ER diagram and write a database design outline for the following prompt: You run...

Draw an ER diagram and write a database design outline for the following prompt:

You run a coaching service to help high school students prepare for the SAT exam. You have a staff of coaches, each of which has an employee ID, an hourly rate (such as $20 per hour), and personal information consisting of their first name, last name, middle name/initial, address information, phone number, mobile phone number, and e-mail address. For each high school student, you want to keep similar personal information and a student ID number, date of birth, and expected date of graduation from high school. Coaching takes place in sessions, to each of which you assign a unique ID number. Each session consists of one coach and one student. In addition to being able to identify the coach and student involved in each session, you want to store its start date/time and end date/time.

In: Computer Science

Complete the program used on the instructions given in the comments: C++ lang #include <string> #include...

Complete the program used on the instructions given in the comments:

C++ lang

#include <string>

#include <vector>

#include <iostream>

#include <fstream>

using namespace std;

vector<float>GetTheVector();

void main()

{

vector<int> V;

V = GetTheVector(); //reads some lost numbers from the file “data.txt" and places it in //the Vector V

Vector<int>W = getAverageOfEveryTwo(V);

int printTheNumberOfValues(W) //This should print the number of divisible values by 7 //but not divisible by 3.

PrintIntoFile(W); //This prints the values of vector W into an output file “output.txt”

}

As you see in the main program, there are four functions. The first function is called “GetVector()” that reads a set of integer, place them into the vector V, and returns the vector to the main program.

The second function is called “GetAverageOfEveryTwoNumber() that takes a vector “V” and finds the average of every two consecutive numbers, place the values into another vector called “W” and returns it to the main program. For example if the Vector is:

10 20 30 40 50 60 70 80 90 100

Then vector “W” should be:

15 25 35 45 55 65 75 85 95

Because (10+20) divided by 2 is 15, and so on.

The next function takes the vector “W” and count how many of the values are divisible by “7” but not divisible by “3”

Finally the last function prints the vector “W” into an output file called “output.txt”

In: Computer Science

How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer...

How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer itself.

In: Computer Science

What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree?...

What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree? What happens if you call VEB-TREE-DELETE with an element that is not in the vEB tree? Explain why the procedures exhibit the behavior that they do. Show how to modify vEB trees and their operations so that we can check in constant time whether an element is present.

In: Computer Science

JAVA: Write a program to perform time conversion. The user will select from the following menu:...

JAVA:

Write a program to perform time conversion. The user will select from the following menu: Hours to minutes Days to hours Minutes to hours Hours to days. Each choice has a separate method which is called when the user makes the selection. Please see the output below: Hours to minutes. 2. Days to hours. 3. Minutes to hours. 4. Hours to days. Enter your choice: 2 Enter the number of days: 5 There are 120 hours in 5 days.

In: Computer Science

Question 4: Business Continuity planning [50 marks] Business Continuity planning involves the creation and validation of...

Question 4: Business Continuity planning [50 marks]

Business Continuity planning involves the creation and validation of a logistical plan that outlines how an organization will recover from a disaster or extended disruption of operations.

a) Identify and discuss the phases of a Business Continuity life cycle. [25 marks]

b) With the aid of examples, discuss the various issues that could indicate that a Disaster Recovery Plan is not in order. [25 marks]

In: Computer Science

TOPIC: DESIGN A SALE WEBSITE Produce a report evaluating the effectiveness and application of interpersonal skills...

TOPIC: DESIGN A SALE WEBSITE

  1. Produce a report evaluating the effectiveness and application of interpersonal skills during the design and delivery process. You should also include an evaluation of your performance in this project and your contribution to the team you worked in.
  2. Also you need to discuss problem-solving and its importance in planning and running an event. You should include a discussion of various problem-solving techniques and justify the solution methodologies used during your project. You should also include a critique of the application of critical reasoning and your experiences of it.

In: Computer Science

Create a generic superclass Shoe, which has at least 3 subclasses with attributes as shown below:...

Create a generic superclass Shoe, which has at least 3 subclasses with attributes as shown below: class Shoe: Attributes: self.color, self.brand class Converse (Shoe): # Inherits from Shoe Attributes: self.lowOrHighTop, self.tongueColor, self.brand = "Converse" class CombatBoot (Shoe): # Inherits from Shoe Attributes: self.militaryBranch, self.DesertOrJungle class Sandal (Shoe): # Inherits from Shoe Attributes: self.openOrClosedToe, self.waterproof Implement the classes in Python. Create a separate test module where 2 instances of each subclass are created. Test the methods by displaying their information.

In: Computer Science

a) What are the most important principals for designing a good input form? b) What would...

a) What are the most important principals for designing a good input form?

b) What would you specifically avoid in designing an input form?

c) Provide examples, good and bad

In: Computer Science