*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
Program Specifications:
You will be writing a Java program called ASCIIRabbit.java that will print the following ASCII objects. There should be two blank lines between each shape and your output must match identically.
Rabbit In A Hat
--------------------
(^\ /^)
\ V /
(o o)
( (@) )
---------
| |
| |
| |
_______
Rabbit Under A Hat
--------------------
_______
| |
| |
| |
---------
/\"/\
() * ()
("")_("")
Rabbit Wears A Hat
------------------
_______
| |
| |
| |
---------
(o o)
( (@) )
/\"/\
() * ()
("")_("")
Style requirements:
displayRabbitWearsHat(); //prints rabbit wearing hat
/* ***********************************************************************************
displayRabbitWearsHat() - Displays the ASCII image of a rabbit wearing a hat
************************************************************************************ */
public static void displayRabbitWearsHat() {
displayRabbitEars();
displayRabbitFace();
displayHatBottom();
//etc.
Once you think you have your program decomposition properly created, test your program to see if your output matches the sample run from above. When it looks correct and you have it properly documented, submit it for grading.
In: Computer Science
Tip Calculator Instructions
For this project you are to create a tip calculator that will take a decimal/or non decimal amount and calculate the different tip values of that amount:
10% 15% 20%
And display them appropriately. The values will be set to two decimal places. If you have an empty value, then a message will display informing the user of such. When the device is rotated the error message or tip information must continue to be displayed.
in Android/Java
In: Computer Science
Python
class LinkedNode:
# DO NOT MODIFY THIS CLASS #
__slots__ = 'value', 'next'
def __init__(self, value, next=None):
"""
DO NOT EDIT
Initialize a node
:param value: value of the node
:param next: pointer to the next node in the LinkedList, default is None
"""
self.value = value # element at the node
self.next = next # reference to next node in the LinkedList
def __repr__(self):
"""
DO NOT EDIT
String representation of a node
:return: string of value
"""
return str(self.value)
__str__ = __repr__
# IMPLEMENT THESE FUNCTIONS - DO NOT MODIFY FUNCTION SIGNATURES #
def insert(value, node=None):
pass
def to_string(node):
pass
def remove(value, node):
pass
def remove_all(value, node):
pass
def search(value, node):
pass
def length(node):
pass
def sum_list(node):
pass
def count(value, node):
pass
def reverse(node):
pass
def remove_fake_requests(head):
pass
Testcases:
import unittest
from LinkedList import insert, remove, remove_all, to_string, search, sum_list, \
count, reverse, length, remove_fake_requests
class TestProject2(unittest.TestCase):
def test_insert(self):
linked_list = insert(0)
insert(1, linked_list)
insert(2, linked_list)
for i in range(0, 3):
assert linked_list.value == i
linked_list = linked_list.next
def test_to_string(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
insert(3, list1)
assert to_string(list1) == "0, 1, 2, 3"
def test_length(self):
list1 = insert(1)
insert(2, list1)
insert(3, list1)
assert length(list1) == 3
def test_search(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
assert search(2, list1)
assert not search(3, list1)
def test_count(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
assert count(0, list1) == 1
assert count(1, list1) == 1
assert count(2, list1) == 1
def test_sum_list(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
insert(3, list1)
assert sum_list(list1) == 6
def test_remove(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
insert(3, list1)
list1 = remove(1, list1)
for i in [0, 2, 3]:
assert list1.value == i
list1 = list1.next
assert list1 == None
def test_remove_all(self):
list1 = insert(0)
insert(1, list1)
insert(0, list1)
insert(2, list1)
insert(3, list1)
insert(0, list1)
list1 = remove_all(0, list1)
test_list = list1
for i in [1, 2, 3]:
assert test_list.value == i
test_list = test_list.next
assert test_list == None
def test_reverse(self):
list1 = insert(0)
insert(1, list1)
insert(2, list1)
insert(3, list1)
list1 = reverse(list1)
for i in [3, 2, 1, 0]:
assert list1.value == i
list1 = list1.next
def test_fake_requests(self):
requests = insert(170144)
insert(567384, requests)
insert(604853, requests)
insert(783456, requests)
insert(783456, requests)
insert(903421, requests)
real_requests = remove_fake_requests(requests)
for i in [170144, 567384, 604853, 903421]:
assert real_requests.value == i
real_requests = real_requests.next
if __name__ == "__main__":
unittest.main()
Thanks!
In: Computer Science