Questions
(C++)Problem #1: Coin Tossing Simulation: Write a program that simulates coin tossing. Let the program prompt...

(C++)Problem #1: Coin Tossing Simulation: Write a program that simulates coin tossing. Let the program prompt the user to enter the number of tosses N and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip() that takes no arguments and returns 0 for tails and 1 for heads. The program should produce different results for each run.

Sample Input / Output

Enter the number of tosses N: 1000

The total number of Heads is: 495

The total number of Tails is: 505

In: Computer Science

PLEASE MAKE UP ANY 3 NONLINEAR PROGRAMMING PROBLEMs BY YOUR OWN AND SOLVE IT in either...

PLEASE MAKE UP ANY 3 NONLINEAR PROGRAMMING PROBLEMs BY YOUR OWN AND SOLVE IT in either EXCEL, matlab or lingo.

In: Computer Science

Sign up for an API Key to consume OpenWeathermap.org and using their Weather API, using Bootstrap,...

Sign up for an API Key to consume OpenWeathermap.org and using their Weather API, using Bootstrap, axios, jQuery create an application that returns weather information for a given Zip Code (see https://openweathermap.org/current#zip), I.e. a form with a zip code input and button that when i click the button it returns the weather information on the DOM.

Even extra points if you handle the loading state so that the user is aware something is loading.

  • Submission should be through github, you should “submit” a link to the github repository
  • The repository should be a single HTML page, a single JavaScript file and optional CSS file(s)
  • As always, HTML, JavaScript and CSS must be valid.
  • As always, JavaScript must not produce any errors.

You can use https://getbootstrap.com/docs/4.4/getting-started/introduction/#starter-template as a starting point

In: Computer Science

Code Using Arrays in Java There is a new ruling for the only elevator located at...

Code Using Arrays in Java

There is a new ruling for the only elevator located at Block B. Students who need to ride the elevator, must line up in a queue. The rated load in pounds for the elevator is based on the inside net platform areas. The maximum load for the elevator is 500 pound.

Write a program to read the students weight (in pound) in the line and calculate the number of students that are allowed to enter the elevator before it makes a loud noise.

Input

The first line of input is T (1 ≤ T ≤ 100) which is the number of test case. This is followed by T lines of input. Each line starts with X (X ≤ 100) which is the number of students who want to ride the elevator. This is then followed by a list of X data which is the students’ weight in the line.

Output

For each test case, the output contains a line in the format "Case #x: y", where x is the case number (starting from 1) and y indicates the number of students in the line that are allowed to ride the elevator.

Sample Input

3
9 45 25 50 46 10 55 50 83 68
5 66 155 93 101 90 
8 64 70 50 45 85 74 110 95 

Sample Output

Case #1: 9
Case #2: 4
Case #3: 7


In: Computer Science

I am wanting to know how to write guessing game program in java that prompts the...

I am wanting to know how to write guessing game program in java that prompts the use to enter a capital for a each of 50 states, one state at a time. Upon receiving the user input, the program reports whether the answer is correct or incorrect. Assume 50 states and their capitals are stored in a two-dimensional array. Attached is a copy of the two-dimensional array that can be copied into your program. The user's answer is not case sensitive.

Sample run:

What is the capital of Alabama? Phoenix

Your answer is incorrect.

What is the capital of Alaska? Juneau

Your answer is correct.

What is the capital of Arizona? phoenix

Your answer is correct.

statecapitals.txt

String[][] stateCapital = {
      {"Alabama", "Montgomery"},
      {"Alaska", "Juneau"},
      {"Arizona", "Phoenix"},
      {"Arkansas", "Little Rock"},
      {"California", "Sacramento"},
      {"Colorado", "Denver"},
      {"Connecticut", "Hartford"},
      {"Delaware", "Dover"},
      {"Florida", "Tallahassee"},
      {"Georgia", "Atlanta"},
      {"Hawaii", "Honolulu"},
      {"Idaho", "Boise"},
      {"Illinois", "Springfield"},
      {"Indiana", "Indianapolis"},
      {"Iowa", "Des Moines"},
      {"Kansas", "Topeka"},
      {"Kentucky", "Frankfort"},
      {"Louisiana", "Baton Rouge"},
      {"Maine", "Augusta"},
      {"Maryland", "Annapolis"},
      {"Massachusettes", "Boston"},
      {"Michigan", "Lansing"},
      {"Minnesota", "Saint Paul"},
      {"Mississippi", "Jackson"},
      {"Missouri", "Jefferson City"},
      {"Montana", "Helena"},
      {"Nebraska", "Lincoln"},
      {"Nevada", "Carson City"},
      {"New Hampshire", "Concord"},
      {"New Jersey", "Trenton"},
      {"New York", "Albany"},
      {"New Mexico", "Santa Fe"},
      {"North Carolina", "Raleigh"},
      {"North Dakota", "Bismarck"},
      {"Ohio", "Columbus"},
      {"Oklahoma", "Oklahoma City"},
      {"Oregon", "Salem"},
      {"Pennsylvania", "Harrisburg"},
      {"Rhode Island", "Providence"},
      {"South Carolina", "Columbia"},
      {"South Dakota", "Pierre"},
      {"Tennessee", "Nashville"},
      {"Texas", "Austin"},
      {"Utah", "Salt Lake City"},
      {"Vermont", "Montpelier"},
      {"Virginia", "Richmond"},
      {"Washington", "Olympia"},
      {"West Virginia", "Charleston"},
      {"Wisconsin", "Madison"},
      {"Wyoming", "Cheyenne"}
    };

In: Computer Science

Create a JUNIT test program in Java for this program: package edu.odu.cs.cs350; import java.util.Arrays; /** *...

Create a JUNIT test program in Java for this program:

package edu.odu.cs.cs350;


import java.util.Arrays;


/**
 * A duration represents a period of elapsed time, e.g., 4 hours, 23 minutes, 2 seconds.
 * This is differentiated from a point in time (e.g., 4:23:02AM). A meeting that
 * has a duration of 2 hours has that same duration no matter where it was held. A 
 * starting time (point) for that of 2:00PM EST can be unambiguous only if the time
 * zone is added.
 * 
 * <p>
 * Because durations are often used in calculations, both positive and
 * negative values are possible.
 * 
 * <p>
 * Most of the accessor functions for this class will respond with normalized
 * values, where the normalization rules are as follows:
 * <ul>
 *   <li>The seconds and minutes components will have an absolute
 *       value in the range 0..59, inclusive.</li> 
 *   <li>The hours component will have an absolute value in the 
 *       range 0..23, inclusive.</li>
 *   <li>The sign of each component matches the sign of the 
 *       overall duration.  A duration of -61 seconds, for example,
 *       has normalized components of -1 seconds and -1 minutes.</li>
 * </ul>
 * Inputs to the member functions are not, however, required to 
 * be normalized. new Duration(0,0,3,-61) and new Duration(0,0,1,59)
 * are both acceptable (and the resulting Duration objects are equal).  
 * 
 * @author zeil
 *
 */
public class Duration implements Cloneable {



  /**
   * Construct a new duration, equivalent to
   * Duration(0,0,0,0).
   */
  public Duration() {
      //ToDo
  }

  /**
   * Create a new duration.
   * 
   * @param totalSeconds total number of seconds in duration
   */
  public Duration(long totalSeconds) {
      //ToDo
  }

  /**
   * Create a new duration.
   * 
   * @param days  number of days in duration
   * @param hours number of hours in duration
   * @param minutes number of minutes in duration
   * @param seconds number of seconds in duration
   */
  public Duration(int days, int hours, int minutes, int seconds) {
      //ToDo
  }

  
  /**
   * Get the total seconds of this duration, including the contributions
   * of the days, hours, minutes, & seconds components.
   *  
   * @return the total seconds
   */
  public long getTotalSeconds() {
      //ToDo
      return 0;
  }

  /**
   * Set the total seconds of this duration, potentially altering
   * the days, hours, minutes, & seconds components.

   * @param totalSeconds the total seconds to set
   */
  public void setTotalSeconds(long totalSeconds) {
      //ToDo
  }

  /**
   * How many days in this duration?.
   * 
   * @return the normalized days component
   */
  public int getDays() {
      //ToDo
      return 0;
  }
  
  private static final long secondsPerHour = 60 * 60; 

  /**
   * How many hours in this duration?.
   * 
   * @return the normalized hours component
   */
  public int getHours() {
      //ToDo
      return 0;
  }

  
  /**
   * How many minutes in this duration?.
   * 
   * @return the normalized minutes component
   */
  public int getMinutes() {
      //ToDo
      return 0;
  }
  

  /**
   * How many seconds in this duration?.
   * 
   * @return the normalized seconds component
   */
  public int getSeconds() {
      //ToDo
      return 0;
  }

  /**
   * Add another duration to this one.
   * @param dur a duration
   */
  public void add(Duration dur) {
      //ToDo
  }

  /**
   * Subtract another duration from this one.
   * @param dur a duration
   */
  public void subtract(Duration dur) {
      //ToDo
  }

  /**
   * Multiply this duration by a scaling factor,
   * rounding to the closest second.
   * @param factor a scaling factor
   */
  public void scale(double factor) {
      //ToDo
  }

  /**
   * Render the duration as
   *     d:h:m:s
   * (preceded by a '-'if the duration is negative)
   * where the four components are normalized non-negative
   * integer values. The final three components are always rendered 
   * in 2 digits. The two leading components and their 
   * associated ':' delimiters are omitted if the leading values
   * are zero.  E.g., Duration(0,-1,-59,-61) would be rendered as
   * "-02:00:01".
   */
  public String toString() {
      //ToDo
      return "";
  }
  
  

  // Comparison and hashing

  /**
   * Compares two durations for equality. They are considered equal if
   * their getTotalSeconds() values are equal.
   *
   * @param obj object to be compared for equality with this duration
   * @return <tt>true</tt> if the specified object is equal to this one
   */
  public boolean equals(Object obj) {
      //ToDo
      return false;
  }

  /**
   * Returns the hash code value for this object.
   *
   * @return the hash code value for this duration
   */
  public int hashCode() {
      //ToDo
      return 0;
  }

  /**
   * Return a (deep) copy of this object.
   */
  @Override
  public Object clone()  {
      //ToDo
      return null;
  }


}

*This is the template to fill in for the solution - please fill in these functions to complete the JUNIT Test Class*

/**
*
*/
package edu.odu.cs.cs350;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
* @author Colten Everitt
*
*/
public class DurationClassTest {

   /**
   * @throws java.lang.Exception
   */
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
   }

   /**
   * @throws java.lang.Exception
   */
   @AfterClass
   public static void tearDownAfterClass() throws Exception {
   }

   /**
   * @throws java.lang.Exception
   */
   @Before
   public void setUp() throws Exception {
   }

   /**
   * @throws java.lang.Exception
   */
   @After
   public void tearDown() throws Exception {
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#hashCode()}.
   */
   @Test
   public final void testHashCode() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#Duration()}.
   */
   @Test
   public final void testDuration() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#Duration(long)}.
   */
   @Test
   public final void testDurationLong() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#Duration(int, int, int, int)}.
   */
   @Test
   public final void testDurationIntIntIntInt() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#getTotalSeconds()}.
   */
   @Test
   public final void testGetTotalSeconds() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#setTotalSeconds(long)}.
   */
   @Test
   public final void testSetTotalSeconds() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#getDays()}.
   */
   @Test
   public final void testGetDays() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#getHours()}.
   */
   @Test
   public final void testGetHours() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#getMinutes()}.
   */
   @Test
   public final void testGetMinutes() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#getSeconds()}.
   */
   @Test
   public final void testGetSeconds() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#add(edu.odu.cs.cs350.Duration)}.
   */
   @Test
   public final void testAdd() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#subtract(edu.odu.cs.cs350.Duration)}.
   */
   @Test
   public final void testSubtract() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#scale(double)}.
   */
   @Test
   public final void testScale() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#toString()}.
   */
   @Test
   public final void testToString() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#equals(java.lang.Object)}.
   */
   @Test
   public final void testEqualsObject() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link edu.odu.cs.cs350.Duration#clone()}.
   */
   @Test
   public final void testClone() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#Object()}.
   */
   @Test
   public final void testObject() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#getClass()}.
   */
   @Test
   public final void testGetClass() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#equals(java.lang.Object)}.
   */
   @Test
   public final void testEqualsObject1() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#clone()}.
   */
   @Test
   public final void testClone1() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#toString()}.
   */
   @Test
   public final void testToString1() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#notify()}.
   */
   @Test
   public final void testNotify() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#notifyAll()}.
   */
   @Test
   public final void testNotifyAll() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#wait(long)}.
   */
   @Test
   public final void testWaitLong() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#wait(long, int)}.
   */
   @Test
   public final void testWaitLongInt() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#wait()}.
   */
   @Test
   public final void testWait() {
       fail("Not yet implemented"); // TODO
   }

   /**
   * Test method for {@link java.lang.Object#finalize()}.
   */
   @Test
   public final void testFinalize() {
       fail("Not yet implemented"); // TODO
   }

}

In: Computer Science

#1: Write a program that optionally accepts an address and a port from the command line....

  1. #1: Write a program that optionally accepts an address and a port from the command line. If there is no address/port on the command line, it should create a TCP socket and print the address (i.e. server mode). If there is an address/port, it should connect to it (i.e. client mode). Once the connections are set up, each side should enter a loop of receive, print what it received, then send a message. The message should be “ping” from the client and “pong” from the server.

Hints:

You will need to pick a port for the server – something over 1024.

Ensure that you open your firewall to let the signal through.

In: Computer Science

7. Using the provided schema of a Purchase Order Administration database, write the following queries in...

7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.)

SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS)

SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD)

PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY)

PO_LINE (PONR, PRODNR, QUANTITY)

PURCHASE_ORDER (PONR, PODATE, SUPNR)

7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status than supplier number 21.

7e) Write a nested SQL query using the keyword IN to retrieve the supplier name of each supplier who supplies more than five products.

In: Computer Science

Discuss best practices for evaluating the performance and effectiveness of the IT governance structure. What should...

Discuss best practices for evaluating the performance and effectiveness of the IT governance structure. What should IT managers consider when evaluating the effectiveness of the IT governance structure? Provide an example of a best practice and how it is relevant to the strategic vision of your organization, or an organization you are familiar w

In: Computer Science

Python question Your code can make use of any of the BinarySearchTree ADT methods: BinarySearchTree(), insert_left(),...

Python question

Your code can make use of any of the BinarySearchTree ADT methods: BinarySearchTree(), insert_left(), insert_right(), get_left(), get_right(), set_left(), set_right(),get_data(), set_data(), search(), __contains__ and insert().

Define a function called create_bst_from_list(values) which takes a list of values as a parameter. The function should create a binary search tree by using the insert() method.

Note: You can assume that the BinarySearchTree class is given and the parameter list is not empty.

For example:

Test Result
tree = create_bst_from_list([7, 12, 4, 9, 20])
print_tree(tree, 0)
7
(L)    4
(R)    12
(L)        9
(R)        20
tree = create_bst_from_list([8, 3, 1, 6, 4, 25, 78])
print_tree(tree, 0)
8
(L)    3
(L)        1
(R)        6
(L)            4
(R)    25
(R)        78
class BinarySearchTree:
    def __init__(self, data, left=None, right=None):
        self.__data = data
        self.__left = left
        self.__right = right
    def insert_left(self, new_data):
        if self.__left == None:
            self.__left = BinarySearchTree(new_data)
        else:
            tree = BinarySearchTree(new_data, left=self.__left)
            self.__left = tree
    def insert_right(self, new_data):
        if self.__right == None:
            self.__right = BinarySearchTree(new_data)
        else:
            tree = BinarySearchTree(new_data, right=self.__right)
            self.__right = tree
    def get_left(self):
        return self.__left
    def get_right(self):
        return self.__right
    def set_left(self, left):
        self.__left = left
    def set_right(self, right):
        self.__right = right
    def set_data(self, data):
        self.__data = data
    def get_data(self):
        return self.__data

I need answers soon. Please!

In: Computer Science

1. List and briefly describe the types of Parallel Computer Memory Architectures. What type is used...

1. List and briefly describe the types of Parallel Computer Memory Architectures. What type is used by OpenMP and why?

2. What is Parallel Programming?

In: Computer Science

Based on your professional and/or educational experience, how often do you believe system log files should...

Based on your professional and/or educational experience, how often do you believe system log files should be checked? How vigilant are you regarding regular checks of these files? When discussing, please also outline some of the reasons why an administrator might tend to ignore these files.

In: Computer Science

Normalizing schema to third normal form (3NF) ,no coding needed! SHIPPING (ShipName, ShipType, VoyageID, Cargo, Port,...

Normalizing schema to third normal form (3NF) ,no coding needed! SHIPPING (ShipName, ShipType, VoyageID, Cargo, Port, ArrivalDate) Key: ShipName, ArrivalDate FD1: ShipName > ShipType FD2: VoyageID > ShipName, Cargo FD3: ShipName, ArrivalDate > VoyageId, Port

1.Normalize SHIPPING to 3NF showing PKs, any FKs, functional dependencies. Show the normal form of the schema at each step in the process (e.g. 2NF?, 3NF?).

2..Please list the final set of 3NF schema including all its keys.

3 .Do any of the finalized 3NF schema have determinates that are not candidate keys? If yes, explain - which schema(s)? Why?

In: Computer Science

function TreeSuccessor(x) if x.right != NIL return TreeMinimum(x.right) // TreeMinimum is on page 291 y =...

function TreeSuccessor(x)
    if x.right != NIL
        return TreeMinimum(x.right)  // TreeMinimum is on page 291
    y = x.p   // parent
    while y != NIL and x == y.right
        x = y
        y = y.p
    return y

Tree-Minimum(x)

1 While x.left != NIL

2     x = x.left

3 return x

Consider the following algorithm.

procedure MysteryWalk(x)
    y = TreeMinimum(x)
    while y != NIL
        print y
        y = TreeSuccessor(y)

Determine what this algorithm does, and compute its running time, giving a justification for your answer.

In: Computer Science

What is the typical application structure in Windows Azure? What type of communication is used to...

What is the typical application structure in Windows Azure? What type of communication is used to exchange data between application components and why?

In: Computer Science