Questions
*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

Using C# visual basics Can someone show a calculator with a button that does a FOR...

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...

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...

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....

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 cell B15, enter a formula that uses the IF function and tests whether the total...

  1. (In cell B15, enter a formula that uses the IF function and tests whether the total sales for Q1 (cell B8) is greater than or equal to 1000000. If the condition is true, multiply the total sales for Q1 by 0.18 to calculate a commission of 18%. If the condition is false, multiply the total sales for Q1 by 0.10 to calculate a commission of 10%.)

In: Computer Science

Program Specifications: You will be writing a Java program called ASCIIRabbit.java that will print the following...

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:

  1. Main comments - Be sure to include a comment in the main method as your begin each shape stating what shape you're about to print...like this:
    displayRabbitWearsHat();   //prints rabbit wearing hat
    
  2. Method comments - Be sure to include a comment above each method that describes the purpose of that method like this
    /* ***********************************************************************************
        displayRabbitWearsHat() - Displays the ASCII image of a rabbit wearing a hat
    ************************************************************************************ */
    public static void displayRabbitWearsHat() {
    
  3. Methods to be used - For this exercise, you will be defining several methods to assist you in drawing the objects and minimizes code redundancy (similar to the egg program we did in lecture). For this exercise, we are going to give you the methods you should use for a proper decomposition.
    • A method called displayRabbitEars: public static void displayRabbitEars() - Draws the portion of the rabbit that includes the ears only.
    • A method called displayRabbitFace: public static void displayRabbitFace() - Similar to above, but this method should display the face of the rabbit.
    • A method called displayRabbitBody: public static void displayRabbitBody() - Similar to above, but this method should display the body of the rabbit.
    • A method called displayHatTop: public static void displayHatTop() - This draws the first line of the hat.
    • A method called displayHatBottom: public static void displayHatBottom() - This draws the last line of the hat.
    • A method called displayHatBody: public static void displayHatBody() - This draws the middle of the hat.
    • A method called displayRabbitInHat: public static void displayRabbitInHat() - So now you can probably see where we are headed. We can draw any of the required rabbits by piecing together the different methods.
              displayRabbitEars();
              displayRabbitFace();
              displayHatBottom();
              //etc.
      
    • Methods for displayRabbitUnderHat() and displayRabbitWearsHat() - Continue using the above logic to develop the remaining rabbit methods. Then tie it all together with a main method that will display the ASCII graphics in the proper order.

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...

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,...

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