Questions
Factorials in Java: Write out your Program Design for how to automate the testing. The objective...

Factorials in Java: Write out your Program Design for how to automate the testing. The objective is to repeat the factorial calculation for different values of n, as n changes from 2, 3, 4, 5, 6, 7..

1) test for an int

2) test for a long

3)test for a double

In: Computer Science

/** * Write a recursive function that accepts a Queue<Integer>. It * should change every int...

/**

* Write a recursive function that accepts a Queue<Integer>. It

* should change every int in this queue to be double its original

* value. You may NOT use loops or any other data structures besides

* the queue passed in as a parameter. You may use a helper function.

* @param q

*/

public static void doubleElements(Queue<Integer> q) {}

In: Computer Science

. Let BT Node be the class we often use for binary-tree nodes. Write the following...

. Let BT Node be the class we often use for binary-tree nodes. Write the following recursive methods: (a) numLeaves: a method that takes a BT Node T as parameter and returns the number of leaves in the tree rooted at T. (b) isEven: a boolean method that takes a BT Node T and checks whether its tree is strictly binary: every node in the tree has an even number of children.

In: Computer Science

Find the Standard Deviation in Java: Use Arrays and Looping. Calculate the Standard Deviation once you...

Find the Standard Deviation in Java: Use Arrays and Looping. Calculate the Standard Deviation once you have the m numbers in an Array of size m. *Don't use different methods

In: Computer Science

C# Write a console application that takes the following passage and removes every instance of the...

C#

Write a console application that takes the following passage and removes every instance of the word "not" using StringBuilder and prints the result out to the console:

I do not like them
In a house.
I do not like them
With a mouse.
I do not like them
Here or there.
I do not like them
Anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.

Ensure that the resulting output reads normally, in other words, it must maintain the same line breaks and not include double-spaces where there should only be a single space. The output should be identical to this:

I do like them
In a house.
I do like them
With a mouse.
I do like them
Here or there.
I do like them
Anywhere.
I do like green eggs and ham.
I do like them, Sam-I-am.

In: Computer Science

Note: Present results using fprintf()and comment your code throughout. Write a function that will compute the...

Note: Present results using fprintf()and comment your code throughout.

  1. Write a function that will compute the volume and surface area of a rectangular prism when provided with the object’s 3 numerical dimensions. In other words, the function should be given three inputs (height, width and depth) and return two outputs (the volume and surface area, in that order). Show the following test cases:
    1. height: 5   width:3    depth: 2
    2. heignt:1    width:8    depth:4
    3. height: 2   width:2    depth:10

The script should call the function 3 times and store the results of the three test cases in two row vectors called vol and sa.

Function specifications:

Input arguments: length, width, height - all scalars. (Order does not matter)

Output arguments: volume, area - both scalars. (Must be in this order)

OPTIONAL: If you prefer, you can write the function such that the input and output arguments are arrays; in that case, only one call to the function is necessary.

In: Computer Science

** * Write a recursive function that removes the first k even numbers * from the...

**

* Write a recursive function that removes the first k even numbers

* from the stack. If there are less than k even elements in the stack,

* just remove all even elements. Do not use any loops or data structures

* other than the stack passed in as a parameter.

* @param stack

* @param k

* @return Returns the number of elements removed from the stack.

*/

public static int removeEvenNumbers(Stack<Integer> stack, int k) {

return 0;

}

In: Computer Science

Complete class Cow so that it has: (a) an int attribute to hold a number of...

Complete class Cow so that it has:

(a) an int attribute to hold a number of legs,
(b) a constructor that takes one parameter, a number of legs (c) a getter method for the attribute
(d) a method to convert any instance of Cow to a string

    class Cow{
        ____________________________________
        ____________________________________
        Cow(________________________){
        ____________________________________
        ____________________________________
        }
        ____ getNumLegs(){
        ____________________________________
        ____________________________________
        }
        ____________________________________
        ____________________________________
        ____________________________________
        ____________________________________
        ____________________________________

}

public class MinOfSet {

    /**
     * Write a method (use the code provided) that takes
     * a collection of Cows and
     * returns the Cow that has the minimum number of legs.
     * Assume the collection contains at least one cow.
     */

    public static Cow minCow(Collection<Cow> herd){
        Cow answer = null;
        Iterator<Cow> icow = herd.iterator();
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________

}

public static void main(String[] args) {
//Put two cows in the herd and then print the cow with minimum legs
Collection<Cow> herd = new HashSet<>();
____________________________________
____________________________________
____________________________________
____________________________________

In: Computer Science

*in Java 1.Create a card class with two attributes, suit and rank. 2.In the card class,...

*in Java

1.Create a card class with two attributes, suit and rank.

2.In the card class, create several methods:

a. createDeck – input what type of deck (bridge or pinochle) is to be created and output an array of either 52 or 48 cards.

b.shuffleDeck – input an unshuffled deck array and return a shuffled one.

+ Create a swap method to help shuffle the deck

c. countBridgePoints – inputs a 13-card bridge ‘hand’-array and returns the number of high-card points

d. writeHandOutput – input a bridge-hand and prints it out on the monitor

e. writeDeckOuput – inputs a deck of bridge cards and prints it out on the monitor

  1. main method should:

a. Ask the user what kind of deck he/she wants to create (pinochle or bridge). For this project, have the user input ‘bridge’.

b. Create the user-asked-for deck

c. Print out the unshuffled deck

d. Shuffle the deck

e. Create 4 Bridge hands of 13 cards each, call them North, South, East and West.

+ Deal every fourth card to each of the hands

f. Calculate the high-card-points in each hand

g. Print out each hand and the number of high-card-points associated with each hand

h. Sort the hands from highest to lowest number of points – use Insertion Sort we did before

i. Print out each hands points from highest to lowest.

In: Computer Science

7. Write a function that accepts a sentence as the argument and converts each word to...

7. Write a function that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY.

In: Computer Science

Jeff needs to make a calculation on data in rows of an Excel spreadsheet. He creates...

  1. Jeff needs to make a calculation on data in rows of an Excel spreadsheet. He creates a new column, and in the first row of this column, he writes a formula. He verifies the resulting number is correct. He then double-clicks the bottom right of the cell to perform the same calculation on all other rows in the column (AutoFill). After he double-clicks, he sees the numbers appear. What would be the next thing Tony should do?
    1. Chart the data in a line graph to make sure the data can be plotted.
    2. Select one random row and perform the calculation manually, to get a level of assurance the formula worked correctly for all rows and the correct data is shown.
    3. Change the formula to put a dollar sign (“$”) on both sides of the column letter to ensure the data is locked.
    4. Nothing further needs to be done except to save the workbook file.

In: Computer Science

Write a program that will accept user input for an initial deposit and a total amount...

Write a program that will accept user input for an initial deposit and a total amount the user wants to have, and will output the number of years it will take to reach his/her goal. For the basic program, the user will deposit the initial amount in a new account, and then the account will receive interest, compounded MONTHLY, at a rate of 0.5%. Then modify it by allowing the user to set a fixed amount to be deposited into the account at the beginning of every month. Again, the amount will be input by the user, but will be the same amount every month.

In: Computer Science

Problem 2 Write a program in Java to implement a recursive search function int terSearch(int A[],...

Problem 2

Write a program in Java to implement a recursive search function int terSearch(int A[], int l, int r, int x)

that returns the location of x in a given sorted array of n integers A if x is present, otherwise -1.

The terSearch search function, unlike the binary search, must consider two dividing points

int d1 = l + (r - l)/3

int d2 = d1 + (r - l)/3

For the first call of your recursive search function terSearch you must consider l = 0 and r = A.length - 1.

Important Notes:

• For this problem you must add the main method in your program in order to test your implementation.

  • There are no data errors that need to be checked as all the data will be assumed correct.

• A program that does not compile or does not run loses all correctness points.

In: Computer Science

Benis firm has hired you to develop a database to keep information about its sales offices....

Benis firm has hired you to develop a database to keep information about its sales offices. It has a number of sales offices in several towns. We need to store unique office number and location for each sales office. Each sales office is assigned to one or more employees. You need to store the following information for each employee; unique employee id, employee name, salary and phone number(s). An employee must be assigned to only one sales office. For each sales office, there is always one employee assigned to manage that office. An employee may manage only the sales office to which he/she is assigned. The firm lists property for sale. Attributes of property include a unique property_Id and Location which is made up of Address, City, and Zip Code. Each property must be listed with one (and only one) of the sales offices. Each unit of property has only one owner. For each owner we need to store unique owner_id and owner name. An owner may own one or more properties, and we need to keep the percentage of properties owned by each owner.

REQUIRED:

a) List down the entities, their key attributes and foreign attributes if any.

                                                                                                          

b) Draw an E-R diagram using the above information, clearly showing the

     cardinalities and ordinalities.                                                                         

c) Differentiate between a multi-valued attribute and a composite attribute giving an

      example extracted from the passage.                                                            

                                                                                              [TOTAL: 25 Marks]

In: Computer Science

Follow these steps to implement the following browser-based puzzle game:(Javascript/html/css) 1. Get a photo of yourself...

Follow these steps to implement the following browser-based puzzle game:(Javascript/html/css)
1. Get a photo of yourself and save it as an image file
2. Use a image-splitting program such as splitter.imageonline.co to break the image into 9 roughly equal parts (3 x 3). Save those files in a directory
3. Write Javascript that takes these nine images and randomly rearranges them in a 3 x 3 grid.
4. Each cell in the grid will also have a checkbox.
5. At each turn, the user will click two checkboxes, press a Swap button, and the program will swap the two images that were checked.
6. Play continues until all the sub-images are in their correct positions.
7. The program will state how many turns (swaps) it took to solve the puzzle.
8. Use CSS to make your puzzle game aesthetically (stylistically) pleasing
9. Upload your game (and the photo pieces) to your website.
10. Provide the URL of your puzzle game where it can be tested.

In: Computer Science