Questions
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

The program Nadha Skolar wrote is supposed to read an integer value supplied by the user...

The program Nadha Skolar wrote is supposed to read an integer value supplied by the user that should be between 1-30. Using the value supplied (let's call it n), three different summation formulas should be calculated using three different methods. Nadha Skolar was supposed to write a program to read the user's input, ensure that it is a value between 1-30 and then call the appropriate methods to calculate the summations and print the results:

  • summationN() - Calculates and returns the summation of the first n integers. This should be calculated using n(n+1)/2
  • sumofOddN() - Calculates and returns the summation of the first n odd integers. This should be calculated using n2
  • sumOfSquaresN() - Calculates and returns the sum of squares of the first n integers ∑i2 from 1 to n. This should be calculated using n(n+1)(2n+1)/6

Sample Runs:

Run #1 (bad value for n):

Enter a number between 1-30 for the value of n: 0 <--- user enters the number for n
Program cannot continue. n must be a value 1-30.  <--- use a println

Run #2 (bad value for n):

Enter a number between 1-30 for the value of n: 31  <--- user enters the number for n
Program cannot continue. n must be a value 1-30. <--- use a println

Run #3:

Enter a number between 1-30 for the value of n: 3  <--- user enters the value for n

The summation of the first n numbers is: 6
The summation of the n odd numbers is: 9
The summation of n numbers squared is: 14 <--- use a println

Tips:

  1. Test your program in intelliJ before copying it back to zyBooks.
  2. When the program is working correctly, copy the code from intelliJ back to zyBooks and submit for grading.
  3. Important: You may NOT erase and re-write the entire program or an entire method. Your job is to fix Nadha's thinking and programming.

import java.util.*;

/* Name: NadhaSkolar Solution

public class NadhaStrikesAgain { //my best work yet! I have just learned about methods!
public static void main(String[] args) {

//get the value for n
Scanner scnr = new Scanner(System.in);
int n = getN();

//ensure n is usable
if ((n <= 0) && (n > 30)){
System.out.println("Program cannot continue. n must be a value 1-30.");
}

int sum = summationN(n);
int sumodd = sumofOddN(sum);
int sumSquares = sumOfSquaresN(n);

displayResults(sumodd, sum, sumSquares); //print them out
}
}

// ************************************************
// DESCRIPTION - getN() - prompts for n and returns value to main
// ************************************************
public static void getN(Scanner scnr) {
//prompt for a number,
System.out.print("Enter a number between 1-30 for the value of n: ");
int n = scnr.nextInt();
return n;
}

// ************************************************
// DESCRIPTION - addOdd() computes summation of first "num" odd numbers using the formula n^2
// ************************************************
public static double sumofOddN(int num) {
return(num^2);
}

// ************************************************
// DESCRIPTION - summation() - computes and returns the summation of i from to N
// ************************************************
public static int summationN(int num) {
return(num * num + 1 / 2);
}

// ************************************************
// DESCRIPTION - sumOfSquares() - computes and returns the sum of squares of first "num" numbers
// ************************************************
public static int sumOfSquaresN(int n) {
return((num * (num + 1) * (2 * num + 1) / 6));
}

// ************************************************
// DESCRIPTION - displayResults() - displays the various summations
// ************************************************
public static void displayResults(int sum, int oddSum, int sumSquares) {
System.out.println();
System.out.println("The summation of the first n numbers is: " + sum);
System.out.println("The summation of the n odd numbers is: " + oddSum);
System.out.println("The summation of n numbers squared is: " + sumSquares);
}
}
}

In: Computer Science

Instructions Write a Circle class (Circle.java) that has the following fields: - radius (double) - PI...

Instructions

Write a Circle class (Circle.java) that has the following fields:

- radius (double)

- PI (final double initialized to 3.1415) // no need to have setters or getters for this

Include the following methods:

- Constructor (accepts radius of circle as an argument)

- Constructor (no argument that sets radius to 0.0)

- setRadius (set method for radius field)

- getRadius (get method for radius field)

- calcArea (calculates and returns area of circle: area = PI * radius * radius)

- calcDiameter (calculates and returns diameter of circle: diameter = radius * 2)

- calcCircumference (calculates and returns circumference of circle: circumference = 2* PI * radius)

Write a test program (TestCircle.java) that will ask user for the radius, creates the circle object, and then displays the area, diameter, and circumference.

Make sure to create 2 circle object instances - one with the radius as an argument, one without but sets the radius with the setRadius() method.

Thank you so much for your help!!

In: Computer Science

Create 2 more batch files called devTracker.bat and showTracker.bat as follows: devTracker.bat a. This batch logs...

Create 2 more batch files called devTracker.bat and showTracker.bat as follows:
devTracker.bat
a. This batch logs an entry into a log file called C:\myTemp\devTracker.log
b. The entry in the log file should indicate the date and time of the VS launch as well as a message indicating
that you started Visual Studio. Please log all of this information on 1 line in the devTracker.log file
c. After making this log entry, devTracker.bat should run myStart.bat for you
showTracker.bat
d. Create another batch file called showTracker.bat that displays the contents of the devTracker.log
file in the command prompt window.

In: Computer Science