Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store the grades. Then, using a loop, prompt the user for the test1 and test2 grade of each student. Create a second single-dimensional float array to hold the average grade for each student (for up to 100 students). To calculate the average grade, pass both the two-dimensional array and the single-dimensional array to a function named void calculateAverages(float grades[][2], float averages[], int numStudents). The third parameter of the function indicates the actual number of students. The function will then use a loop to calculate the average grade for each student. Remember, since averages is an array parameter, any changes to averages is changing the original array. When the function returns to main, the program (in main) should display the average grade for each student (using a loop).
In: Computer Science
Please solve in C++ only
class is not templated
You need to write a class called LinkedList that implements the following List operations:
public void add(int index, Object item);
// adds an item to the list at the given index, that index may be
at start, end or after or before the
// specific element
2.public void remove(int index);
// removes the item from the list that has the given index
3.public void remove(Object item);
// finds the item from list and removes that item from the list
4.public List duplicate();
// creates a duplicate of the list
// postcondition: returns a copy of the linked list
5.public List duplicateReversed();
// creates a duplicate of the list with the nodes in reverse order
// postcondition: returns a copy of the linked list with the nodes in
6.public List ReverseDisplay();
//print list in reverse order
7.public Delete_Smallest();
// Delete smallest element from linked list
8.public List Delete_duplicate();
// Delete duplicate elements from a given linked list.Retain the earliest entries.
9 Make a function that adds a linked list to itself at the end.
Input:
4 -> 2 -> 1 -> NULL
Output:
4 -> 2 -> 1 -> 4 -> 2 -> 1 -> NULL
note : code should work on Visual studio 2017 and provide screenshot of output
In: Computer Science
IN JAVA
Objectives
Practice Link list, List node, compareTo, user defined data type, interfaces
Movie List
Create a link list of the movies along with the rating, number of the people who watched the movie and the genre of the movie.
Required classes
Movie class implements Comparable
Attributes: movie’s name, genre, rating, number of people watched
Methods: constructor, getter, setter, equals, compreTo, toString
ListNode class
Attributes: each node has two attributes
Methods:
Constructors
public ListNode(Movie m): initializes the instance variable
m
public ListNode() : empty body
public ListNode(Movie m, ListNode next): initializes the instance variables m and next
getter methods
public Movie getMovie()
public ListNode getNext()
setter methods
public void setNext(ListNode next)
List interface
public void add(String name, String ganra, int star, int
people);
public void add(int index, String name, String genre, int star, int
people); public int indexOf(String movieName);
public void remove(String movieName);
public int size();
public String toString();
public Movie get(int position);
MovieList implements List :
all the methods in this class must use link list concept
public class MovieList implements List
{
private ListNode front;
public static int size = 0;
//constructor
public MovieList(){}
//add the movie to the end of the list
public void add(String name, String ganra, int star, int people){}
//adds the movie at the given index
public void add(int index, String name, String ganra, int star, int people){}
//returns the movie at the given index
public int indexOf(String movieName){}
//removes the movie from the list
public void remove(String movieName){}
//returns the size of the list
public int size(){}
//create a string from all the movies in the list
public String toString(){}
//returns the movie at the given index
public Movie get (int pos){} //returns the list of the movie with the give star
public String getMovie(int star){}
//return the movie with the max number of peopel watched.
public Movie mostWatched(){}
Driver class
Make sure that your code works with the following driver. Copy and paste this class to your file.
class Driver
{
public static void main (String [] args)
{
MovieList list = new MovieList();
list.add("Reservoir Dogs", "drama",5, 20000);
list.add("Airplane", "Funny", 3, 1200);
list.add("Doctor Zhivago","comedy", 4,23000);
list.add("The Deer Hunter", "Family", 3, 2345);
System.out.println("Here is the list of the movies\n");
System.out.println(list);
System.out.println("\nhere is the the movie that was most
watched");
System.out.println(list.mostWatched());
System.out.println("Here is the list of 5 stars ratings");
System.out.println(list.getMovie(5));
System.out.println("removing Reservoir movie");
list.remove("Reservior Dogs");
System.out.println(list);
System.out.println("Displaying the second movie in the
list");
System.out.println(list.get(1));
System.out.println("adding a movie at position 2");
list.add(2, "Up", "Carton",3,4500);
System.out.println(list);
int i = list.indexOf("Up");
System.out.println("The movie up is in the position " + i);
}
}
Sample output
Here is the list of the movies
Reservoir Dogs, drama, *****, 20000
Airplane, Funny, ***, 1200
Doctor Zhivago, comedy, ****, 23000
The Deer Hunter, Family, ***, 2345
here is the the movie that was most watched
Doctor Zhivago, comedy, ****, 23000
Here is the list of 5 stars ratings
Reservior Dogs, drama, *****, 20000
removing Reservoir movie
Airplane, Funny, ***, 1200
Doctor Zhivago, comedy, ****, 23000
The Deer Hunter, Family, ***, 2345
Displaying the second movie in the list
Doctor Zhivago, comedy, ****, 23000
adding a movie at position 2
Airplane, Funny, ***, 1200
Doctor Zhivago, comedy, ****, 23000
Up, Carton, ***, 4500
The Deer Hunter, Family, ***, 2345
The movie up is in the position 2
In: Computer Science
/*
* File: ListDriver.java
* Assignment: Lab03
* Author:
* Date:
* Course:
* Instructor:
*
* Purpose: Test an implementation of an array-based list ADT.
* To demonstrate the use of "ListArrayBased" the project
driver
* class will populate the list, then invoke various
operations
* of "ListArrayBased".
*/
import java.util.Scanner;
public class ListDriver {
/*
* main
*
* An array based list is populated with data that is
stored
* in a string array. User input is retrieved from that
std in.
* A text based menu is displayed that contains a
number of options.
* The user is prompted to choose one of the available
options:
* (1) Build List, (2) Add item, (3) Remove item, (4)
Remove all items,
* or (5) done. The switch statement manages calling
the
* appropriate method based on the option chosen by the
user, and
* prompts the user for further input as required
Program terminates
* if user chooses option (5). If the user chooses an
option that is
* not in the menu, a message telling the user to
choose an appropriate
* option is written to std out, followed by the
options menu.
*/
public static void main(String[] args)
{
String[] dataItems =
{"milk","eggs","butter","apples","bread","chicken"};
// TO DO: add code here
} // end of main method
/*
* Displays the options menu, including the
prompt
* for the user
*/
public void displayMenu()
{
// TODO: add code here
}
/*
* displayStatus
*
* displays information about the state of
* the list
*
* Preconditions: a reference to a list
*
* Postconditions:
* "List empty: B" where B is either TRUE or
FALSE
* and "Size of list: n" where n is the size of
* the list is written to std out.
*/
public void displayStatus(ListArrayBased list)
{
// TO DO: add code here
}
/*
* displayList
*
* Precondition: a reference to a list
*
* Postcondition: list is displayed on std out
*/
public void displayList(ListArrayBased list)
{
// TO DO: add code here
}
/*
* buildList
*
* Precondition: a reference to a list and an string
array
* of items to be address to the list
*
* Postcondition: items stored the string array are
added
* to the list.
*/
public void buildList(ListArrayBased list, String[]
items)
{
// TO DO: add code here
}
/*
* addItem
*
* Precondition: a reference to a list, a String
* representing a grocery item, and the integer
* pos is the position in the list
*
* Postcondition: an item is added to the list at
* position pos.
*/
public void addItem(ListArrayBased list, String item,
int pos)
{
// TO DO: add code here
}
/*
* removeItem
*
* Precondition: a reference to a list and
* int pos;
*
* Postcondition: item is removed from the list by
its
* position pos.
*/
public void removeItem(ListArrayBased list, int
pos)
{
// TO DO: add code here
}
/*
* removeAllItems
*
* Precondition: a reference to a list
*
* Postcondition: all items currently stored in the
list
* are removed
*/
public void removeAllItems(ListArrayBased list)
{
// TO DO: add code here
}
} // end of class ListArrayBasedDriver
In: Computer Science
Question 15 (1 point)
It is believed that students who begin studying for final exams a week before the test score differently than students who wait until the night before. Suppose you want to test the hypothesis that students who study one week before score greater than students who study the night before. A hypothesis test for two independent samples is run based on your data and a p-value is calculated to be 0.0428. What is the appropriate conclusion?
Question 15 options:
|
|||
|
|||
|
|||
|
|||
|
Question 16 (1 point)
You are looking for a way to incentivize the sales reps that you are in charge of. You design an incentive plan as a way to help increase in their sales. To evaluate this innovative plan, you take a random sample of your reps, and their weekly incomes before and after the plan were recorded. You calculate the difference in income as (after incentive plan - before incentive plan). You perform a paired samples t-test with the following hypotheses: Null Hypothesis: μD ≥ 0, Alternative Hypothesis: μD < 0. You calculate a p-value of 0.0542. What is the appropriate conclusion of your test?
Question 16 options:
|
|||
|
|||
|
|||
|
|||
|
Question 17 (1 point)
It is reported in USA Today that the average flight cost nationwide is $325.69. You have never paid close to that amount and you want to perform a hypothesis test that the true average is actually less than $325.69. The hypotheses for this situation are as follows: Null Hypothesis: μ ≥ 325.69, Alternative Hypothesis: μ < 325.69. If the true average flight cost nationwide is $300.92 and the null hypothesis is not rejected, did a type I, type II, or no error occur?
Question 17 options:
|
|||
|
|||
|
|||
|
|||
|
In: Statistics and Probability
/**
* This class implements a basic Binary Search Tree that supports
insert and get operations. In
* addition, the implementation supports traversing the tree in
pre-, post-, and in-order. Each node
* of the tree stores a key, value pair.
*
* @param <K> The key type for this tree. Instances of this
type are used to look up key, value
* pairs in the tree.
* @param <V> The value type for this tree. An instance of
this type is stored in every node, along
* with a key.
*/
public class BST<K extends Comparable<K>, V> {
/**
* Interface for
*
* @param <K> the key type that the traverser works with
* @param <V> the value type that the traverser works
with
*/
public interface Traverser<K, V> {
/**
* Method that is called for every visited node.
*
* @param key the key stored in the visited node
* @param value the value stored in the visited node
*/
public void visit(K key, V value);
}
/**
* A tree traverser that prints all values stored in the visited
nodes.
*/
private static class IntegerValuePrintTraverser implements
Traverser<Integer, Integer> {
/**
* This method is called for every visited node, printing the value
stored in the node.
*/
public void visit(Integer key, Integer value) {
System.out.println(value);
}
}
/**
* Nested node class for the tree. Stores a key, value pair and has
references to left and right
* child.
*/
private class Node {
public K key = null;
public V value = null;
public Node left = null;
public Node right = null;
/**
* Construct a tree node for a give key, value pair.
*
* @param key The key stored in the node. This determines where in
the tree the node will be
* inserted.
* @param value The value stored in the node alongside the
key.
*/
public Node(K key, V value) {
this.key = key;
this.value = value;
}
}
// the root node reference for the tree; is null is tree is
empty
private Node root = null;
// number of nodes stored in the tree
private int size;
/**
* Insert a new key, value pair into the tree.
*
* @param key
* @param value
* @throws IllegalArgumentException if key is null or if key is
already present in tree
*/
public void insert(K key, V value) {
if (key == null) {
throw new IllegalArgumentException("null key not allowed");
}
this.root = this.insertRecursive(this.root, key, value);
this.size++;
}
/**
* Recursive helper method for the public insert method. Recursively
traverses the tree and find
* the spot to insert given key.
*
* @param node node that is currently visited
* @param key the key to insert
* @param value the value to insert
* @return return the node that is visits to (re-)attach it to the
tree
*/
private Node insertRecursive(Node node, K key, V value) {
if (node == null) {
return new Node(key, value);
} else if (node.key.equals(key)) {
throw new IllegalArgumentException("no duplicate keys
allowed");
} else if (node.key.compareTo(key) < 0) {
// new key is larger than current key
node.right = insertRecursive(node.right, key, value);
return node;
} else {
// new key is smaller then current key
node.left = insertRecursive(node.left, key, value);
return node;
}
}
/**
* Retrieve value that is stored for given key in the tree.
*
* @param key the key to look for in the tree
* @throws IllegalArgumentException if key is null
* @return value for key or null if key does not exist in tree
*/
public V get(K key) {
if (key == null) {
throw new IllegalArgumentException("null key not allowed");
}
Node n = getNodeForKey(this.root, key);
if (n == null)
return null;
return n.value;
}
/**
* Recursive helper method for the public insert method. Recursively
traverses the tree and find
* the spot to insert given key.
*
* @param node node that is currently visited
* @param key the key to insert
* @param value the value to insert
* @return return the node that is visits to (re-)attach it to the
tree
*/
private Node getNodeForKey(Node n, K key) {
if (n == null) {
return null;
} else if (n.key.equals(key)) {
return n;
} else if (n.key.compareTo(key) < 0) {
return getNodeForKey(n.right, key);
} else {
return getNodeForKey(n.left, key);
}
}
/**
* Starts a postorder traversal of the tree.
*
* @param t the traverser to do the traversal with
*/
public void postOrderTraversal(Traverser<K, V> t) {
this.postOrderTraversal(this.root, t);
}
/**
* Helper method that traverses the tree recursively in postorder
and calls the traverser for
* every node.
*
* @param n the node that is currently visited
* @param t the traverser to do the traversal with
*/
private void postOrderTraversal(Node n, Traverser<K, V> t)
{
if (n != null) {
postOrderTraversal(n.left, t);
postOrderTraversal(n.right, t);
t.visit(n.key, n.value);
}
}
/**
* Starts a preorder traversal of the tree.
*
* @param t the traverser to do the traversal with
*/
public void preOrderTraversal(Traverser<K, V> t) {
this.preOrderTraversal(this.root, t);
}
/**
* Helper method that traverses the tree recursively in preorder and
calls the traverser for every
* node.
*
* @param n the node that is currently visited
* @param t the traverser to do the traversal with
*/
private void preOrderTraversal(Node n, Traverser<K, V> t)
{
if (n != null) {
t.visit(n.key, n.value);
preOrderTraversal(n.left, t);
preOrderTraversal(n.right, t);
}
}
/**
* Starts an inorder traversal of the tree.
*
* @param t the traverser to do the traversal with
*/
public void inOrderTraversal(Traverser<K, V> t) {
this.inOrderTraversal(this.root, t);
}
/**
* Helper method that traverses the tree recursively in inorder and
calls the traverser for every
* node.
*
* @param n the node that is currently visited
* @param t the traverser to do the traversal with
*/
private void inOrderTraversal(Node n, Traverser<K, V> t)
{
if (n != null) {
inOrderTraversal(n.left, t);
t.visit(n.key, n.value);
inOrderTraversal(n.right, t);
}
}
/**
* Main method with a demo for the tree traverser.
*
* @param args the command line arguments passed when running the
program
*/
public static void main(String args[]) {
BST<Integer, Integer> bst = new BST<Integer,
Integer>();
// map keys to their squares (values)
bst.insert(7, 49);
bst.insert(2, 4);
bst.insert(10, 100);
bst.insert(1, 1);
bst.insert(8, 64);
System.out.println("pre order traversal:");
bst.preOrderTraversal(new IntegerValuePrintTraverser());
System.out.println("in order traversal:");
// TODO: replace this in order traversal's
IntegerValuePrintTraverser object with
// the object of an anonymous class that only prints the keys (not
the values)
// in the visited nodes
bst.inOrderTraversal(new IntegerValuePrintTraverser());
System.out.println("post order traversal:");
// TODO: replace this post order traversal's
IntegerValuePrintTraverser object with
// the object of a lambda expression that prints both the key and
value in the
// visited nodes
bst.postOrderTraversal(new IntegerValuePrintTraverser());
}
}
In: Computer Science
Problem: Make linkedList.h and linkList.c in Programming C language
Project description
This project will require students to generate a linked list of playing card based on data read from
a file and to write out the end result to a file.
|
linkedList.h |
Create a header file name linkedList |
|
Include the following C header files:
Create the following macros:
|
|
|
Add the following function prototypes:
|
|
|
Add a typedef struct definition named card and aliased as Card as follows:
|
|
|
Add a global variable:
|
|
|
linkedList.c |
Create a C source code file named linkedList.c |
|
Include the user defined header file names linkedList.h |
|
|
main() |
1. Read data file 2. Display deck of cards 3. Write data file 4. Exit Program
|
|
readDataFile |
|
|
addCard() |
|
|
display() |
|
|
writeDataFile() |
|
In: Computer Science
1-You are a hospital administrator who grants privileges to several local doctors. Your liability insurance carrier wants to know what steps you are taking to ensure the competence of those doctors. Provide a list to the insurance company that outlines what you look for in your doctors. Your goal is to be as complete as possible. Why? If you're not, the insurance company will deny the policy, and leave your hospital open to liability. No pressure, but your job is on the line if the company denies the policy.
2-Now you represent the insurance company. Read through the posts that your fellow students submitted as their first post. Find a post that interests you, then respond to it. Remember, you are now representing the insurance company. Your goal is to question the hospital's ability to find competent doctors. Are they covering their bases? Should the hospital be considering other factors when granting privileges to doctors? If this hospital does grant privileges to incompetent doctors, your job is on the line. Why? Because you provided the hospital with a policy, and it will have to pay on a malpractice suit if one of their doctors is negligent. So be thorough!
In: Operations Management
Purpose
To calculate your personal RDA for protein. Most adults consume
more than adequate amounts of protein for growth, repair and
maintenance of the human body. There are some of us, however, that
fall short of our daily intake. The roles of protein make it the
MOST versatile of all the energy nutrients and also one of the most
critical. It is always interesting to see how much protein you
really need on a daily basis so this activity will let you write a
menu to reflect meeting those protein needs. Don't go over board
but be sure to meet the RDA. Most students are surprised how easily
we do meet our protein recommendations.
Directions
In: Nursing
Deletion of Product Line
St. Gallen American School is an international private elementary school. In addition to regular classes, after-school care is provided between 3:00 pm and 6:00 pm at CHF 10 per child per hour. Financial results for the after-school care for a representative month are as follows:
|
Revenue, 750 hours at CHF 10 per hour CHF 7,500 Less Teacher salaries CHF 5,300 Supplies 1,200 Depreciation 1,700 Sanitary engineering 200 Other fixed costs 400 8,000 Operating income (loss) CHF(1,300) |
The director of St. Gallen American School is considering discontinuing the after-school care services because it is not fair to the other students to subsidize the after-school program. He thinks that eliminating the program will free up CHF 1,300 a month to support regular classes.
In: Accounting