Questions
Topics Loops while Statement Description Write a program that computes the letter grades of students in...

Topics Loops while Statement Description Write a program that computes the letter grades of students in a class from knowing their scores in a test. A student test score varies from 0 to 100. For a student, the program first asks the student’s name and the student’s test score. Then, it displays the student name, the test score and the letter grade. It repeats this process for each student. The user indicates the end of student data by entering two consecutive forward slashes ( // ) when asked for the student name. At the end, the program displays a summary report including the following: · The total number of students. · The total number of students receiving grade “A”. · The total number of students receiving grade “B”. · The total number of students receiving grade “C”. · The total number of students receiving grade “D”. · The total number of students receiving grade “F”. The program calculates a student's the letter grade from the student's test score as follows: A is 90 to 100 points B is 80 to 89 points C is 70 to 79 points D is 60 to 69 points F is 0 to 59 points. Requirements Do this exercise using a While statement and an If/Else If statement. Testing For turning in the assignment, perform the test run below using the input data shown Test Run (User input is shown in bold). Enter Student Name Alan Enter Student Score 75 Alan 75 C Enter Student Name Bob Enter Student Score: 90 Bob 90 A Enter Student Name Cathy Enter Student Score 80 Cathy 80 B Enter Student Name Dave Enter Student Score: 55 Dave 55 F Enter Student Name Eve Enter Student Score 85 Eve 85 B Enter Student Name // Summary Report Total Students count 5 A student count 1 B student count: 2 C student count 1 D student 0 F students 1 Sample Code string name; double score; //Initias setup cout << "Enter student name" << endl; cin >> name; //Test while (name != "//") { cout << "Enter student score" << endl; cin >> score; //more code here //Update setup out << "Enter student name" << endl; cin >> name; } //display summary report

In: Computer Science

Write a static method called generateSubstrings that adds all subsets of the letters in its first...

Write a static method called generateSubstrings that adds all subsets of the letters in its first argument to the ArrayList that is its second argument.

For example, generateSubstrings("ABC", result); adds to result the strings: "", "A", "B", "C", "AB", "AC", "BC", "ABC" The order of the strings does not matter. You may use iteration for this problem

Use Java

In: Computer Science

Write an article about Networking in video games (Hera) not necessarily about (Hera game) , but...

Write an article about Networking in video games (Hera) not necessarily about (Hera game) , but it should be about Networking or the system used in video games.

In: Computer Science

1.what is the Internet of Things(IoT)?What are the benefits and risks? 2.What are three cyber security...

1.what is the Internet of Things(IoT)?What are the benefits and risks?
2.What are three cyber security issues?
3.How are Internet standards developed?

In: Computer Science

1) What steps can you take to ensure that code changes made to your dependencies will...

1) What steps can you take to ensure that code changes made to your dependencies will not impact your code?

2) Describe the process of mocking and give some examples of scenarios where it might be used. How does this help us?

In: Computer Science

Since images are two dimensional arrays of pixels, and we can represent a pixel as a...

Since images are two dimensional arrays of pixels, and we can represent a pixel as a one-dimensional list of three integers, we can represent an image as a three dimensional matrix (that is, a list of lists of lists) of integers in Python. In the following problems, you will be manipulating matrices of this format in order to alter image files in various ways.

Part 4: Edge Detection Filter

We want to highlight pixels that are significantly brighter (in at least one of the color components) than their surrounding pixels. A sudden shift in brightness like this is bound to occur along any sharp visible edge. To accomplish this, we’ll take each pixel, multiply its color values by 8, and then subtract the color values of the 8 pixels that surround it on the grid. Pixels that are very similar to their surrounding pixels will then end up with a color close to black, since 8 times the color component of that pixel minus the color components of its 8 neighbors should end up around 0.  

This means that for a pixel located at (x,y) in the original image with original red color value r(x,y), you can compute the red component for the pixel the new image r’(x,y) with the following formula:

r’(x,y) = 8*r(x,y) - r(x-1,y-1) - r(x,y-1) - r(x+1,y-1) - r(x-1,y) - r(x+1,y) - r(x-1,y+1) - r(x,y+1) - r(x+1,y+1)

A similar formula applies for the green and blue components. Note that this may produce a value that is above the maximum color component value of 255: if this occurs then you should just set the value to 255. Similarly, if the formula generates a negative number, just set the value to 0.  

For pixels along the boundaries of the picture that do not have 8 neighbors, ignore the formula and set their pixel values to black ([0, 0, 0]), to avoid the issue of going out of bounds.

Constraints:

  • Do not import/use any Python modules except for copy (see part C hints)

  • Do not change the function names or arguments.

  • Your submission should have no code outside of the function definitions (comments are fine).

  • You are permitted to write helper functions outside of the ones provided in the template..

Examples:

edge_detect([[[0,0,10], [0,0,20], [0,0,30], [0,0,200]],

    [[255,120,20], [70,120,30], [0,120,40], [0,0,60]],

    [[0,120,30], [255,120,40], [0,120,60], [0,120,50]],

    [[255,120,40], [255,120,60], [255,120,50], [255,120,40]]])

Output:

[[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],

[[0, 0, 0], [50, 255, 0], [0, 255, 0], [0, 0, 0]],

[[0, 0, 0], [255, 0, 0], [0, 120, 110], [0, 0, 0]],

[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]

In: Computer Science

Write a C++ or Java code that does similar swap action: def swap (Lst, indexA, indexB)...

Write a C++ or Java code that does similar swap action:

def swap (Lst, indexA, indexB) :

    t = Lst[indexA]

    Lst[indexA] = Lst[indexB]

    Lst[indexB] = t

L = [1,2,3,4,5,6,7,8,9,10]

i=3

j=7

print(L[i], L[j])

swap(L,i,j)

print(L[i],L[j])

In: Computer Science

I have code for an AVL tree. I Have have a node class and tree class....

I have code for an AVL tree. I Have have a node class and tree class. I need a  node object that refrences the root(top) of the tree. my current code throws NullPointerException when I try to access the root properties. here is the important snippets of my code, it is in java.

public class Node {
    private Node left=null,right=null;
    public int height=1;
    private String Item;
    private int balance=0; 
    Node(String item) { 
    this.Item=item; }
}
--------------------------------------------------
public class AVLTree {
    public Node root;
    public AVLTree(){
     root=null;
 }
public void insert(String str){
    AVLTree t = new AVLTree();
    root.setItem(str);
    root=t.insert(root,str);
}
public void delete(String str){
    AVLTree t = new AVLTree();
    root.setItem(str);
    t.deleteNode(root,str);
}
private Node insert(Node node, String str) {
    deleteNode(node, str);   
    if (node == null) {
        return(new Node(str));
    }
    if (str.compareTo(node.getItem()) <1)
        node.setLeft(insert(node.getLeft(),str));
    else
        node.setRight(insert(node.getRight(),str));
    node.height = Math.max(height(node.getLeft()), height(node.getRight())) + 1;
    int balance = getBalanceNode(node);
    if (balance > 1 && str.compareTo(node.getLeft().getItem())<1)
        return rightRotate(node);
    if (balance < -1 && str.compareTo(node.getRight().getItem())>1)
        return leftRotate(node);
    if (balance > 1 && str.compareTo(node.getLeft().getItem())>1)
    {
        node.setLeft(leftRotate(node.getLeft()));
        return rightRotate(node);
    }
    if (balance < -1 &&str.compareTo(node.getRight().getItem())<1)
    {
        node.setRight(rightRotate(node.getRight()));
        return leftRotate(node);
    }
    return node;
}
private Node deleteNode(Node node, String str) {
    if (node == null)
        return node;
    if (str.compareTo(node.getItem())<1)
        node.setLeft(deleteNode(node.getLeft(),str));
    else if( str.compareTo(node.getItem())>1)
        node.setRight(deleteNode(node.getRight(),str));
    else {
        if( (node.getLeft() == null) || (node.getRight() == null) ) {
            Node temp;
            if (node.getLeft() != null)
                temp = node.getLeft();
            else
                temp = node.getRight();
            if(temp == null) {
                temp = node;
                node = null;
            }
            else
                node = temp;
            temp = null;
        }
        else {
            Node temp = minValueNode(node.getRight());
            node.setItem(temp.getItem());
            node.setRight(deleteNode(node.getRight(),temp.getItem()));
        }
    }
    if (node == null)
        return node;
    node.height = Math.max(height(node.getLeft()), height(node.getRight())) + 1;
    int balance = getBalanceNode(node);
    if (balance > 1 && getBalanceNode(node.getLeft()) >= 0)
        return rightRotate(node);
    if (balance > 1 && getBalanceNode(node.getLeft()) < 0) {
        node.setLeft(leftRotate(node.getLeft()));
        return rightRotate(node);
    }
    // Right Right Case
    if (balance < -1 && getBalanceNode(node.getRight()) <= 0)
        return leftRotate(node);
    // Right Left Case
    if (balance < -1 && getBalanceNode(node.getRight()) > 0) {
        node.setRight(rightRotate(node.getRight()));
        return leftRotate(node);
    }
    return node;
}}

In: Computer Science

Conduct an internet search on how to build a web portal ? no copy subject e-...

Conduct an internet search on how to build a web portal ?

no copy subject e- portals development

In: Computer Science

Write a Java function to swap two integers.

Write a Java function to swap two integers.

In: Computer Science

What would the output be for the following program code segment? #define ROWS  3      #define COLS 3...

What would the output be for the following program code segment?

#define ROWS  3     

#define COLS 3

void addCoulmns(int arr[][COLS],int Sum[COLS]);

int main(void)

{

       int array[ROWS][COLS] = {{ 10, 35, 23 },

                                  { 5, 4, 57 },

                                  { 4, 7, 21 }};

       int ColSum[ROWS];

       int rows;

       int columns;

       addCoulmns(array,ColSum);

       for (columns = 0; columns < COLS - 1; columns++)

              printf("%d\n",ColSum[columns]);

       return(0);

}

void addCoulmns(int arr[][COLS],int Sum[COLS])

{

       int row;

       int col;

       for (col = 0; col < COLS - 1; col++)

       {

              Sum[col] = 0;

              for (row = 0; row < ROWS - 1; row++)

                      Sum[col] += arr[row][col];

       }

       return;

}

In: Computer Science

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