Questions
how to implement h / k sqrt(n) in c h being a constant k being the...

how to implement h / k sqrt(n) in c
h being a constant
k being the students k(k < 10^9)
n is the two mid points in a ternary search

in c programing

In: Computer Science

Consider the below database schema for company ABC: Employee(empNo, givename, famname, gender, DOB) Supervises(super_empNo*, empNo*, description)...

Consider the below database schema for company ABC:

Employee(empNo, givename, famname, gender, DOB)

Supervises(super_empNo*, empNo*, description)

Department(deptNo, name, manager_empNo*)

Dependent(empNo*, name, relationship)

Project(projNo, description, deptNo*)

The relations Employee, Supervises, Department, Dependent and Project keep data for employees, supervision, departments, dependents of employees and projects of ABC.

For the database, primary keys, and parent and child relations for foreign keys are annotated. The meaning of most attributes is self-explanatory. Answer questions below.

Your answer to each question must be according to the given database schema and instance.

1.1. (2 points) Does the primary key of Supervises (super_empNo, empNo) ensure that each supervisor supervises a different employee? Explain your answer.

1.2. (5 points) Is it possible that a project has no department? Explain why/why not. If possible, identify any data integrity constraints that can be placed on the Project table to prevent this? Can a project have many departments? Explain using the data integrity constraints on the Project table.

1.3. (2 points) Is it possible that a supervisor does not supervise any employees? Explain your answer using the data constraints on the Supervises table.

1.4 (3 point) Assuming that every department is working on at least one project (and the Department table contains a record with department number 8), can the SQL statement below be successfully executed? Explain your answer. DELETE FROM Department WHERE deptNo = 8;

In: Computer Science

You are to draw the AVL trees that result after inserting each of the following keys...

You are to draw the AVL trees that result after inserting each of the following keys in the order given: TCG, TAC, AAC, TGg, TTC, ACC, GGC. You will draw a total of 7 trees, one after each insertion

In: Computer Science

Create the following tables. The underlined bold column names are the primary keys. Make sure to...

Create the following tables. The underlined bold column names are the primary keys. Make sure to specify the primary and foreign key constraints in your create table statements.

  1. customer: (cus_code:integer, cus_lname:varchar(20), cus_fname:varchar(20), cus_initial:char, cus_areacode:integer,cus_phone:integer).

  1. invoice: (inv_number:integer, cus_code:integer, inv_date:date,

                  foreign key cus_code references customer(cus_code))

  1. vendor:(vend_code:integer,vend_name:varchar(30),vend_contact:varchar(30),vend_areacode:integer,vend_phone:integer)
  1. product:(prod_code:integer, prod_desc:varchar(50), prod_price:integer, prod_quant:integer,vend_code:integer,

foreign key (vend_code) referenecs Vendor(vend_code))

  1. line: (inv_number:integer, prod_code:integer ,line_units:integer,

foreign key (inv_number) references Invoice(inv_number),

foreign key (prod_code) references Product (prod_code) )

In: Computer Science

Given the following data, illustrate Selection Sort. index 1 2 3 4 5 6 data 11...

  1. Given the following data, illustrate Selection Sort.

index

1

2

3

4

5

6

data

11

10

21

3

7

5

In: Computer Science

I need Java Code for both questions....thx Question 1 Consider the sequence of integers defined as...

I need Java Code for both questions....thx

Question 1

Consider the sequence of integers defined as follows:

  • The first term is any positive integer.

  • For each term n in the sequence, the next term is computed like this: If n is even, the next term is n/2. If n is odd, the next term is 3n+1.

  • Stop once the sequence reaches 1.
    Here are a few examples of this sequence for different values of the first term:

    • 8,4,2,1
    • 12,6,3,10,5,16,8,4,2,1
    • 19,58,29,88,44,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1

    Note that all three of these eventually do reach 1. In fact, it is believed (but not known) that the sequence will always reach 1, regardless of the first term chosen. This is known as the Collatz conjecture. Despite its apparent simplicity, it has so far eluded all attempts at a proof. Mathematician Jeffrey Lagarias at the University of Michigan has claimed that “this is an extraordinarily difficult problem, completely out of reach of present day mathematics.”

    We might not be able to prove the Collatz conjecture here, but we can experiment computationally with it! Within your Lab4HW folder, write a program named Collatz.java that allows the user to enter any positive integer. The program should then compute and list all the terms of the sequence until it reaches 1. At the end, show how many terms it took to get to 1 (including 1 itself).

1

Here are some examples of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running.

Example 1

Enter starting value (must be a positive integer): 5
5
16
8
4
2
1
Number of terms: 6

Example 2

Enter starting value (must be a positive integer): 12
12
6
3
10
5
16
8
4
2
1
Number of terms: 10

Example 3

Enter starting value (must be a positive integer): 1
1
Number of terms: 1

Question 2

Credit card numbers are not completely random sequences; they follow certain rules depending on the card issuer. A MasterCard number must meet these criteria:

• Begin with 51, 52, 53, 54, 55, or something in the range 222100-272099
• 16 digits in length
• Satisfy the Luhn formula, created by IBM scientist Hans Peter Luhn in the 1950s

Here’s how the Luhn formula works:

  • Double every other digit going backwards, starting from the next-to-last digit.

  • For each of the doubled values that exceed 9, subtract 9.

  • Add up all the doubled values, along with the digits that were not doubled.

  • If the result is a multiple of 10, the number satisfies the Luhn formula. If the result is not a multiple of 10, the number does not satisfy the Luhn formula.

    For example, 2221008763790559 is a valid MasterCard number. (Don’t worry, this was randomly gener- ated and most likely doesn’t actually belong to anyone :) You can easily verify that the number begins with 222100 and is 16 digits long. To check whether it satisfies the Luhn formula:

    Original number:

    2221008763790559

    Double every other digit going left, starting from the next-to-last digit:

      4  2  4  1  0  0 16  7 12  3 14  9  0  5 10  9
    

    For every doubled value that exceeds 9, subtract 9:

    4241007733590519

    Finally,addupallthemodifieddigits: 4+2+4+1+0+0+7+7+3+3+5+9+0+5+1+9=60, which is indeed a multiple of 10.

    Within your Lab4HW folder, write a program named MasterCardValidator.java that allows the user to enter a credit card number. The program should then determine and print whether that number is a valid MasterCard number according to the criteria above. You can use the randomly generated MasterCard numbers from https://www.freeformatter.com/credit-card-number-generator-validator.html to help you test.

  • Hint: There are several ways you can read the number from the user, but I recommend reading it as a string. You can then use strName.charAt(i) to get the individual digits. However, these are treated as char values rather than int values. To convert to int, you can use one of the following:

    • For a single digit: Integer.parseInt("" + strName.charAt(i)), or strName.charAt(i) - ’0’

    • For multiple digits: Integer.parseInt(strName.substring(startIndex, endIndex))
    Here are some examples of what your completed program might look like when you run it. Underlined

    parts indicate what you type in as the program is running.

    Example 1

    Enter a card number for validation: 2221008763790559
    Valid
    

    Example 2

    Enter a card number for validation: 2221018763790559
    Invalid
    

    Example 3

    Enter a card number for validation: 55
    Invalid
    

In: Computer Science

Insert the following data in the tables using insert into statements: 1. customer: 10010, Johnson, Alfred,...

Insert the following data in the tables using

insert into

statements:

1.

customer:

10010, Johnson, Alfred, A, 615, 8442573

10011, Dunne, Leona, K, 713, 8941238

10012, Smith, Walter, W, 615, 8942285

10013, Roberts, Paul, F, 615, 2221672

10014, Orlando, Myla, NULL, 615, 2971228

2.

invoice:

1001, 10011, 2008-08-03

1002, 10014, 2008-08-04

1003, 10012, 2008-03-20

1004, 10014, 2008-09-23

3.

vendor:

232, Bryson, Smith, 615, 2233234

235, Walls, Anderson, 615, 2158995

236, Jason, Schmidt, 651, 2468850

4.

product:

12321, hammer, 189 ,20, 232

65781, chain, 12, 45, 235

34256, tape, 35, 60, 236

12333, hanger, 200 ,10, 232

5.

line:

1001, 12321, 1

1001, 65781, 3

1002, 34256, 6

1003, 12321, 5

1002, 12321, 6

In: Computer Science

I am trying to write a simple game in Java named GuessNumber.java to run on the...

I am trying to write a simple game in Java named GuessNumber.java to run on the command line. This program asks user to pick a number and the computer guesses the number repetitively until the guess is correct and will allow the user to set the lower and upper bound as command line parameters from where the picks the number. If no command line parameters are specified then the program uses a default of 1 to 99.

In: Computer Science

2. Dice rolling (15 pts) Problem Description: Write a program that rolls a pair of six-sided...

2. Dice rolling (15 pts) Problem Description: Write a program that rolls a pair of six-sided dice, then displays their values sum.

• You can use the random method of the Math class to generate a random number for a die like this: (int) (Math.random() * 6) + 1;

• The application should display special messages for two ones (snake eyes) and two sixes (box cars).

• The application should use static methods (at least two) to organize its code.

• The application should continue only if the user enters “y” or “Y” at the “Roll again?” prompt.

Here is a sample run:

Dice Roller

Roll the dice? (y/n): y

Die 1: 3

Die 2: 1

Total: 4

Roll again? (y/n): y

Die 1: 1

Die 2: 1

Total: 2 Snake eyes!

Roll again? (y/n): y

Die 1: 6

Die 2: 6

Total: 12 Boxcars!

Roll again? (y/n): n

Good bye!

This is for java please check for debugging ! also please leave comments so I could follow steps and better understand

In: Computer Science

(Palindrome integer) Write the methods with the following headers // Return the reversal of an integer,...

(Palindrome integer) Write the methods with the following headers
// Return the reversal of an integer, i.e., reverse(456) returns 654
public static int reverse(int number)
// Return true if number is a palindrome
public static boolean isPalindrome(int number)

Use the reverse method to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.

Here is a sample run: (red indicates a user input)

Enter a positive integer: 12321

12321 is a palindrome.

Continue? (y/n) y

Enter a positive integer: 12345

12345 is not a palindrome.

Continue? (y/n) n

Good bye!

This is for java if you could make it so it is debugged so theres no inputs that could make it crash! :(

Please leave comments

In: Computer Science

using python #You've been sent a list of names. Unfortunately, the names #come in two different...

using python

#You've been sent a list of names. Unfortunately, the names
#come in two different formats:
#
#First Middle Last
#Last, First Middle
#
#You want the entire list to be the same. For this problem,
#we'll say you want the entire list to be Last, First Middle.
#
#Write a function called name_refixer. name_refixer should have two
#parameters: an output filename (the first parameter) and the
#input filename (the second parameter). You may assume that every
#line will match one of the two formats above: either First Middle
#Last or Last, First Middle.
#
#name_refixer should write to the output file the names all
#structured as Last, First Middle. If the name was already structured
#as Last, First Middle, it should remain unchanged. If it was
#structured as First Middle Last, then Last should be moved
#to the front and a comma should be added after it.
#
#The names should appear in the same order as the original file.
#
#For example, if the input file contained the following lines:
#David Andrew Joyner
#Hart, Melissa Joan
#Cyrus, Billy Ray
#
#...then the output file should contain these lines:
#Joyner, David Andrew
#Hart, Melissa Joan
#Cyrus, Billy Ray


#Add your code here!

#The code below will test your function. You can find the two
#files it references in the drop-down in the top left. If your
#code works, output_file.txt should have the text:
#Joyner, David Andrew
#Hart, Melissa Joan
#Cyrus, Billy Ray
name_refixer("output_file.txt", "input_file.txt")
print("Done running! Check output_file.txt for the result.")

#If you accidentally erase input_file.txt, here's its original
#text to copy back in (remove the pound signs):
#David Andrew Joyner
#Hart, Melissa Joan
#Cyrus, Billy Ray

In: Computer Science

Problem: Your have been asked by a cell phone service provider to write a program that...

Problem: Your have been asked by a cell phone service provider to write a program that will calculate the amount of a customer’s monthly bill. Write a C++ program that will calculate the amount of the bill given the number of lines and the amount of minutes used during the month. Unlimited texting is also offered. '

The cellular service provider offers the following options and pricing: One line for $6/month base cost. Two lines for $12/month base cost.

The voice rates are as follows:

• No minutes: $0

• 1-400 minutes: $9 total

• 401-800 minutes: $16 total

• over 800 minutes: $16 + 1.9 cents/minute over 800 Unlimited texting is $5 extra.

Input: The program should ask the user if they have (A) one line or (B) two lines. Then the program should ask the user to input the number of minutes used in the month (no fractional amounts) Then the program should ask if the user has unlimited text messages (Y or N).

For the first two input values, use an if statement to perform input validation. The user should select only A, or B for the number of lines, and the minutes should be between 0 and 44640 (inclusive).

If either input is invalid, the program should ask the user to reenter the value (but only once, no looping).

Do not validate the response to the last question. 1 Processing: Compute the amount of the monthly bill according to the descriptions above.

If the user answered ‘y’ or ‘Y’ to the last question, your program should add $5 to the bill.

Output: Display the amount of the monthly bill with a dollar sign and formatted to 2 decimal places.

Here are 5 different sample executions of the program: How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 100 Unlimited text messages? (Y/N): N The amount due for the month is $15.00

How many lines: A. One line B. Two lines B Enter the total number of minutes used during the month: 750 Unlimited text messages? (Y/N): Y The amount due for the month is $33.00

How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 850 Unlimited text messages? (Y/N): Y The amount due for the month is $27.95

How many lines: A. One line B. Two lines A Enter the total number of minutes used during the month: 803 Unlimited text messages? (Y/N): y The amount due for the month is $27.06 2 How many lines: A. One line B. Two lines C Please enter A, or B: A Enter the total number of minutes used during the month: 1234567 Please enter a number between 0 and 44640 for the minutes: 500 Unlimited text messages? (Y/N): n The amount due for the month is $22.00

In: Computer Science

WEEK 6 ASSIGNMENT Using your RFP or the Desktop Lab Project from Week Five - write...

WEEK 6 ASSIGNMENT

  • Using your RFP or the Desktop Lab Project from Week Five - write a detailed scope statement, and then
  • Answer the following questions:
    1. What problem or opportunity does the project address?
    2. What quantifiable results are to be achieved?
    3. What needs to be done?
    4. How will success be measured?
    5. How will we know when we are finished?

In: Computer Science

Your data science experiment now requires four additional data tasks. The first task is to use...

Your data science experiment now requires four additional data tasks. The first task is to use the list append method to add to the list variable named btcdec1 the BTC price of 14560. The second task is to create a new list with a variable named btcdec2 and append the btc prices of 15630, 12475, and 14972. The third task required you to use the list extend method to add the contents of the list in variable name btcdec2 into the variable name btcdec1. The fourth and final task requires you to use the list sort method in the list named btcdec1 to sort the items in the newly extended list, then use the print statement to output the content of list btcdec1 into the Python console.

In: Computer Science

NEED ASAP PLEASE IF THIS CANNOT BE ANSWERED WITHIN 1 HOUR TO 1.5 HOURS MAX PLEASE...

NEED ASAP PLEASE IF THIS CANNOT BE ANSWERED WITHIN 1 HOUR TO 1.5 HOURS MAX PLEASE DO NOT DO

I DON'T NEED PROBLEMS 1-4 PLEASE ANSWER 5-7 ONLY. ONLY LISTED 1-4 AS A REFERENCE.

This should be in

Type of application :Console application

Language used :C#

Program.cs :

Problem 1:

(15 pts)

Write a C# console program that continually asks the user "Do you want

to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters

either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and

then get keyboard input of the name. After entering the name, display the name to the screen.

Problem 2:

(20 pts) Create a Patient class which has private fields for patientid, lastname,

firstname, age, and email. Create public properties for each of these private fields with get and

set methods. The entire lastname must be stored in uppercase. Create a main class which

instantiates a patient object and sets values for each data item within the class. Display the

data in the object to the console window.

Problem 3:

(15 pts) Modify the Patient class with two overloaded constructors: A new default

constructor which initializes the data items for a patient object using code within the

constructor (use any data). A second constructor with parameters to pass all the data items

into the object at the time of instantiation. Create a test main class which instantiates two

objects. Instantiate the first object using the default constructor and the second object using

the constructor with the parameters.

Problem 4:

(10 pts) Add a static display method in the main class in the patient application

that has a parameter to pass a patient object and display its content.

Problem 5:

(10 pts) Modify the patient class with two overloaded methods to display a bill for a

standard visit based on age. In the first method do not use any parameters to pass in data. If

the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard

doctors office visit is $125. Build a second method where you pass in a discount rate. If the

patient is over 65, then apply the discount rate to a standard rate of $125. Create a main

method that calls both of these methods and displays the results.

Problem 6:

(20 pts) Create two subclasses called outpatient and inpatient which inherit from

the patient base class. The outpatient class has an additional data field called doctorOfficeID

and the inpatient class has an additional data item called hospitalID. Write a main method that

creates inpatient and outpatient objects. Sets data for these objects and display the data.

Problem 7:

( 10 pts) Modify the base class of Problem 6 to be an abstract class with an abstract

display method called displayPatient that does not implement any code. Create specific

implementations for this method in both the outpatient and inpatient subclasses.

In: Computer Science