Note: Present results using fprintf()and comment your code throughout.
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 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 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, 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
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 “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
In: Computer Science
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[], 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. 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 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
Using C# visual basics
Can someone show a calculator with a button that does a FOR LOOP about 10x time and does a print out of a name 10x
In: Computer Science
Using C# visual basics
Can someone show a calculator with a button that does a While LOOP about 10x time and does a print out of a name 10x
In: Computer Science
a.) Let T be a binary tree with n nodes. Define the lowest common ancestor (LCA) between two nodes v and w as the lowest node in T that has both v and w as descendants. Given two nodes v and w, write an efficient algorithm, LCA(v, w), for finding the LCA of v and w. Note: A node is a descendant of itself and v.depth gives a depth of a node v.
b.) What is the running time of your algorithm? Give the asymptotic tight bound (Q) of its running time in terms of n and justify your answer.
In: Computer Science
Write and test a Python program to print a set of real numbers in descending order. The program should also print out the median of the numbers input and how many numbers were input. The program should read in numbers until a negative number is read. The negative number serves as a sentinel or marker telling the program when to stop reading numbers. The program should then sort the numbers and print them out in order from largest to smallest. Note, the sentinel number is not to be considered as one of the numbers, it should not be printed. The program should be able to handle up to 100 input numbers. If the user attempts to enter more than 100 numbers, the program should print an error message and quit.
Also do not use list methods like list.append etc. or import any libraries to solve this problem.
Here is the template to work off of:
# get the numbers and input into the list
def get_numbers(nums):
# stop when -99.0 is entered
i = 0;
while i < 10:
nums[i] = input("Enter a number: ")
if nums[i] == -99.0:
break
i = i + 1
return i # returning the total number of numbers entered
# output all num numbers
def print_numbers(nums, num):
# output each number one line at a time
for i in range(num):
print nums[i]
# output the numbers joining each with a space between on one line
print (" ".join(str(x) for x in nums[0:num]))
# output the list
print nums
#####################
# the "boss" function
#####################
def main():
num_numbers = 0 # initialize num_numbers to 0
a = [0.0] * 10 # initialize a list of 10 floating point values to 0.0
num_numbers = get_numbers(a)
print_numbers(a, num_numbers)
# if python program was executed from this source code
if __name__ == "__main__":
main()
In: Computer Science
In: Computer Science