Questions
Represent -60 in binary using 8-bit signed magnitude. Add the following unsigned 8 bit binary numbers...

Represent -60 in binary using 8-bit signed magnitude.

Add the following unsigned 8 bit binary numbers as shown. 01110101 + 00111011

Add the following unsigned 8 bit binary numbers as shown. 01000100 + 10111011

In: Computer Science

Let A[1..n] be an array of distinct positive integers, and let t be a positive integer....

  1. Let A[1..n] be an array of distinct positive integers, and let t be a positive integer.

    (a) Assuming that A is sorted, show that in O(n) time it can be decided if A contains two distinct elements x and y such that x + y = t.
    (b) Use part (a) to show that the following problem, re- ferred to as the 3-Sum problem, can be solved in O(n2) time:
    1. 3-Sum

      Given an array A[1..n] of distinct positive integers, and a positive integer t, determine whether or not there are three distinct elements x, y, z in A such that x+y+z = t.

In: Computer Science

Create an application that checks whether an integer is an odd or even number. Welcome to...

Create an application that checks whether an integer is an odd or even number.

Welcome to the Odd/Even Checker! Enter an integer: ten Error! Invalid integer. Try again. Enter an integer: 10.3 Error! Invalid integer. Try again. Enter an integer: 10 The number 10 is even. Continue? (y/n): Error! This entry is required. Try again. Continue? (y/n): y Enter an integer: 9 The number 9 is odd. Continue? (y/n): n

Specifications:

Create a version of the Console class presented in chapter 7 that doesn’t use static methods. Create a MyConsole class that inherits the Console class. Then, override the getString() method so it doesn’t allow the user to enter an empty string. Use an instance of the MyConsole class to get and validate the user’s entries.

In: Computer Science

JAVA Remember the childhood game “Rock, Paper, Scissors”? It is a two-players game in which each...

JAVA

Remember the childhood game “Rock, Paper, Scissors”? It is a two-players game in which each person simultaneously chooses either rock, paper, or scissors. Rock beats scissors but loses to paper, paper beats rock but loses to scissors, and scissors beats paper but loses to rock. Your program must prompt the player 1 and player 2 to each enter a string for their choice: rock, paper, or scissors. Then appropriately reports if “Player 1 wins”, “Player 2 wins”, or “It is a tie.” Your program should work for both lower case and uppercase letters. If the user string is not rock, scissors or paper the program will print “Wrong choice”.

Sample Run: User input is in Bold.

Player 1: Choose rock, scissors, or paper:

rock

Player 2: Choose rock, scissors, or paper:

paper

Player 2 wins.

Player 1: Choose rock, scissors, or paper:

scissors

Player 2: Choose rock, scissors, or paper:

rock

Player 2 wins.

Player 1: Choose rock, scissors, or paper:

PAPER

Player 2: Choose rock, scissors, or paper:

Rock

Player 1 wins.

Player 1: Choose rock, scissors, or paper:

rock

Player 2: Choose rock, scissors, or paper:

pen

Wrong choice!

In: Computer Science

Managing Data (R language) Reference (Chapter : 4 Managing Data from textbook - Practical Data Science...

Managing Data (R language)

Reference (Chapter : 4 Managing Data from textbook - Practical Data Science With R, 1st edition By Nina Zumel and John Mount
Publisher: Manning, ISBN 13: 978-1-617291-56-2)

1 . Explain how you would handle missing data in categorical and numerical variables?

2. Give few data transformation techniques and cases where you would be applying them.

3. Briefly explain the log transformation and when it should be used.

In: Computer Science

Create a super class named Vehicle, which has the following attributes: VIN, engine size, Year, Speed....

Create a super class named Vehicle, which has the following attributes: VIN, engine size, Year, Speed. Check

Add a subclass named Car, which has the following additional attributes: Wheel size, Model, Miles (OOD). Check

Add another subclass to the vehicle superclass named Boat which has the following additional attributes: Hours, Gas type, Type (Fishing Boat, Deck boat, bowrider boat), and Check

Write a method named DisplayInfo() in your main to display the information of the Vehicle. In this method print all the features of the vehicle.

Add a method in each class to estimate the price of the vehicle subclasses base on some factors of each type. And call this method from the method DisplayInfo().

In the main method create three objects one of type Vehicle, the second of type Cars, and the third of type Boat.

I have the classes and variables made. How would i create the object (i know how to create) and pass this information to the display info.

Java language

In: Computer Science

Part 1 Write a C++ program in which you define the following logical functions: 1) contradictory...

Part 1 Write a C++ program in which you define the following logical functions:

1) contradictory function (¬?)

2) logical and (? ∧ ?)

3) logical inclusive or (? ∨ ?)

4) implication function (? → ?)

5) biconditional (? ↔ ?)

6) logical exclusive or (? ⨁ ?)

You can find the logical definitions for the above functions as given by Bertrand Russell in your text. You need to write a method (function) for each corresponding logical function. The input and output values for each of these functions should be type boolean. Here are the prototypes:

For each of the following propositions, notice the variables are to be assigned some truth values. Using your functions from part 1, evaluate the truth or falsity of the proposition under the specified assignment. Do this in the same source file as for part 1.

Proposition 1: (? → ?) ∧ (¬? → ?) with c and b are F, a is T.

Proposition 2: (? → ?) ∨ (? ↔ ¬(¬? ⨁ ¬?)) with p is T, q and r are F.

In: Computer Science

1. Practice searching 2. Continue learning the significance of special cases! 3. Learning how to write...

1. Practice searching

2. Continue learning the significance of special cases!

3. Learning how to write test to check your implementation

Things you must do:

1. There are many details in this lab. Make sure you read the whole thing carefully before writing any code and closely follow this instruction.

2. Always remember Java is case sensitive.

3. Your file names, class names, and package name must match exactly as they are specified here.

Things you must not do:

1. You must not change the file names, class names, package names.

2. You must not change the signature of any of these methods (name, parameters, …). Just fill in the missing code inside them. However, you are more than welcome to create any helper methods you need as necessary.

Part 1 - BinarySearchSet Class Description For this lab (and assignment), you are asked to construct a class called BinarySearchSet that handles a list(s) of doubles. We have provided the skeleton of this class for you. This class requires: • All of the usual operations for a list, such as the ability to add items, remove items, search for items, grow itself before running out of space.

• You must make your search routine(s) as efficient as possible. You are not allowed to use sort algorithms. Instead, you need to consider the fact that any list will begin as an empty list (which is already in sorted order), and you can simply insert items in the correct order to ensure that the list remains sorted at all times.

• Furthermore, the list must not contain any duplicates.

• The data in BinarySearchSet must be backed by a basic array (do not use a Java List, ArrayList, or any other Java class).

• It is not acceptable for the array to run out of space for new items, nor is it acceptable to create a gigantic array. Start with a modestly-size array, let’s say 6, and increase the capacity as needed (see the grow() function description).

• Unlike previous assignments you are not given any tests as a starting point. You must create your own tests and submit them with your program. (Note that the previous assignment will be very useful in helping you accomplish this).

Part 2 – BinarySearchSet Class Implementation We start by implementing the easier methods. Remember that the list must be sorted at all times. Please pay close attention to the following notes:

• public BinarySearchSet() //default constructor o This constructor will create a storage array of size 6 (an initial size for an empty list) o and set the rest of the field members accordingly. Pay attention to the member variables of the class! Each should be set to some (appropriate) initial value.

• public boolean isEmpty() o returns true only if this list contains no elements • public int size() o returns the number of elements in this list • public void grow() o this function doubles the size of the storage array and modifies member variables accordingly. o consult this week’s slides

• public String toString() o this method will print the elements of the list, its capacity, and its current size. o This method is purely to help you test your implementation. We will NOT test your toString() method when grading.

• private int sequentialFind(double target) o this method will return the index where the element target occurs. This method must make use of the Sequential search we learned in class. If target is not present in the list, then it should return the index where it should be added (-index - 1). Does this formula make sense? o There are three cases to consider. What should be returned in each? § target is equal to storage[index] § target becomes less than storage[index] § the loop terminates without success

• public boolean insert(double newVal) o If the list does not contain newVal, add it to the correct position of the list and return true. If the list already includes the value, return false. o The method should first make sure there is enough room in the list to handle the operation. If not, what should you do? o It should then make a call to findIndex(), which then calls the private sequentialFind you just implemented, to see if newVal already occurs in the list (how do we know?). If it isn’t in the list, the index returned by findIndex specifies the position where newVal is to be inserted (but it is negative! what should you do? :-) o Be careful about which member variables should be updated before returning true.

• public void clear() o Removes all the elements from the list. A call to isEmpty() should return true after this method is called. o Be careful about which member variables should be updated.

Part 3 – BinarySearchSet Class Implementation – Phase 2 THIS PART IS NOT OPTIONAL Unlike previous labs/assignments you are not given any tests as a starting point. You must create your own tests to examine each method you implemented. These tests can be written inside Tester.java. Here is a testing strategy: create an empty list. Then, check its size, check whether it is empty. Then, start adding a couple of numbers to your list and make sure your list adds them properly (that is, they are in the sorted order, the other member variables reflect the changes, etc). Then, continue adding values to your list till you go beyond its original capacity. Make sure you are not having any error in this case and that the list does indeed grow. Finally, test your clear to see if all elements are removed from the list.

package lab05;

public class BinarySearchSet {
   /** represent the simple array that holds the list values */
   public double[] storage;
   /** holds the length of the storage array */
   private int capacity;
   /** holds the number of elements in the list */
   private int size;

   /** keep this TRUE for lab **/
   public boolean labFind = true;

   /** default constructor */
   public BinarySearchSet(){
       public double[] storage;
       private int capacity;
       private int numItems;
   }

   public BinarySearchSet(double[] input){
       // TODO (for assignment, not lab)
   }

   public boolean isEmpty(){
       // TODO
       return false; //placeholder
   }

   public int size(){
       // TODO
       return 0; //placeholder
   }

   public void grow(){
       // TODO
   }

   public String toString(){
       // TODO
       return null; // placeholder
   }

   public void clear() {
       // TODO
   }

   public boolean insert(double newVal){
       // TODO
       return false;
   }

   public boolean remove(double element){
       // TODO
       return false; // placeholder
   }


   private int sequentialFind(double target) {
       // TODO
       return 0; //placeholder
   }

   private int binaryFind(double target) {
       // TODO
       return 0; // placeholder
   }

   public int findIndex(double target) {
       if (labFind) {
           return sequentialFind(target);
       } else {
           return binaryFind(target);
       }
   }

   public boolean containsAll(double[] elements){
       // TODO
       return false; // placeholder
   }

   public boolean contains(double element){
       // TODO
       return false; // placeholder
   }

}

package lab05;

public class Tester {


}

In: Computer Science

How would I write a code from this following word problem? 3. Use the pow() and...

How would I write a code from this following word problem?

3. Use the pow() and sqrt() functions to compute the roots of a quadratic equation. Enter the three coefficients with a single input statement. Warning: if you give sqrt() a negative value, the function cannot produce a valid answer.

In: Computer Science

Every COBOL program I've browsed professionally has had Paragraph numbers. It is somewhat of Programmer Preference/Art...

Every COBOL program I've browsed professionally has had Paragraph numbers. It is somewhat of Programmer Preference/Art within some general guidelines established by the organization. Reference the references based on your searches, and provide:

1) What you think are the purposes & advantages of numbering paragraphs.

2) Guidelines you suggest for numbering paragraphs.

Please do not cut/paste website text. I've already read that, and that is really the only wrong answer here. The idea of the assignment is assimilate, ascertain & express in simple terms the purpose, advantage & guidelines you'd suggest. This is not a novel; use brief paragraphs and or bullet points.

Lincoln was asked to appear upon some important occasion and deliver a five-minute speech, he said that he had no time to prepare five-minute speeches, but that he could go and speak an hour at any time. The point here, is that with a little planning, it does not take a lot of words to express your point.


i understand this is COBOL but i still need help there is no selection for cobol programming

In: Computer Science

Case Study Baseball Team Manager For this case study, you’ll use the programming skills that you...

Case Study Baseball Team Manager

For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game.

After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then, after you complete most of the other chapters, you can enhance and improve this program.   1

General guidelines

Naming

When creating the folder and file names for your programs, please use the conventions specified by your instructor. Otherwise, for a program that consists of a single file, use this naming convention: first_last_baseball_wkXX.py where first_last specifies your first and last name and wkXX specifies the chapter number, as in wk05. For programs that have multiple files, store the files in a folder named first_last_baseball_wkXX.

When creating names for variables and functions, please use the guidelines and recommendations specified by your instructor. Otherwise, use the guidelines and recommendations specified in Murach’s Python Programming.

User interfaces

You should think of the user interfaces that are shown for the case studies as starting points. If you can improve on them, especially to make them more user-friendly, by all means do so.

Specifications

You should think of the specifications that are given for the case studies as starting points. If you have the time to enhance the programs by improving on the starting specifications, by all means do so.

Top-down development

Always start by developing a working version of the program. That way, you’ll have something to show for your efforts if you run out of time. Then, you can build out that version of the program until it satisfies all of the specifications.

From chapter 5 on, you should use top-down coding and testing as you develop your programs. You might also want to sketch out a hierarchy chart for each program as a guide to your top-down coding.

Improve number and string formatting

Update the program to improve the formatting of the numbers and the strings.

Console

================================================================

Baseball Team Manager

MENU OPTIONS

1 – Display lineup

2 – Add player

3 – Remove player

4 – Move player

5 – Edit player position

6 – Edit player stats

7 - Exit program

POSITIONS

C, 1B, 2B, 3B, SS, LF, CF, RF, P

================================================================

Menu option: 1

POS

AB

H

AVG

Player

----------------------------------------------------------------

1

Denard Span

CF

545

174

0.319

2

Brandon Belt

1B

533

127

0.238

3

Buster Posey

C

535

176

0.329

4

Hunter Pence

RF

485

174

0.359

5

Brandon Crawford

SS

532

125

0.235

6

Eduardo Nunez

3B

477

122

0.256

7

Joe Panik

2B

475

138

0.291

8

Jarrett Parker

LF

215

58

0.270

9

Madison Bumgarner

P

103

21

0.204

Menu option: 7

Bye!

!!Specifications !! (Question that needs to be answered

Use the multiplication operator to make sure that horizontal separator lines use 64 characters

Use spaces, not tabs, to align columns. This should give the program more control over how the columns are aligned.

Make sure the program always displays the batting average with 3 decimal places. Display the positions by processing the tuple of valid positions.

In: Computer Science

1. Create a color image of size 200 × 200. The image should have a blue...

1. Create a color image of size 200 × 200. The image should have a blue background.

2. Create 100 yellow regions within the image that have a variable size. More specifically, their width should be an odd number and vary between 3 and 7 and their height should also be an odd number and vary between 3 and 7. For example, you may get rectangular regions of size 3 × 3, 3 × 5, 5 × 3, 5 × 5, 7 × 5, etc. These 100 yellow regions should be placed at random locations within the 200 × 200 image, but we should make sure that they do not overlap with each other. Important: These regions should be created by modifying the image pixels, and not as plots on top of the image. In other words, these regions should be part of the image.

3. Plot horizontal and vertical white lines on top of the image for every 40 pixel rows and every 40 pixel columns. Now, these white lines will not be part of the image, but an extra layer on top of the image. You may use hold on and hold off, and also plot to achieve this. Display the image with the yellow regions and the white lines in figure(1).

This is what i have for 1 and 2, which is working correctly

clear all;
close all;
clc;

im=zeros(200,200,3);%image
im(:,:,3)=1;
for i=1:100
while true;
  
w=2*round(1+2*rand(1,1))+1;
h=2*round(1+2*rand(1,1))+1;
  
x=round(1+(199-w)*rand(1,100));
y=round(1+(199-h).*rand(1,100));
  
x_dash=x+w;
y_dash=y+h;
  
if all(im(x:x_dash,y:y_dash,2)!=1)
im(x:x_dash,y:y_dash,3)=0;
im(x:x_dash,y:y_dash,1:2)=1;
break;
end
end
end

Need help with Part 3

In: Computer Science

[PYTHON] Two natural number p,q are called coprime if there are no common prime factors in...

[PYTHON] Two natural number p,q are called coprime if there are no common prime factors in their prime factorization. E.g. 15 and 20 are not coprime because 5 is a common prime number in their prime factorization, while 20 and 9 are coprime. The Euler’s phi function, φ(n), counts the number of all natural numbers ≤ n which are coprime to n. E.g. φ(9) = 6, as all natural numbers ≤ 9 are 1,2,3,4,5,6,7,8,9. And out of these, the numbers coprime to 9 are 1,2,4,5,7 and 8, a total of 6 natural numbers.

You are required to write a Python function totient(n) that accepts a natural number as input argument and returns the following:

1. a list of all the natural numbers less than or equal to n which are coprime to n; and

2. the result of the Euler’s phi function when run on n.

E.g. totient(9) should return [1,2,4,5,7,8], 6

You can use your function prime factors from Problem 2. to determine if two numbers are coprime or not.

In: Computer Science

Create a program that asks the user to input three numbers and computes their sum. This...

Create a program that asks the user to input three numbers and computes their sum. This sounds simple, but there's a constraint. You should only use two variables and use combined statements. You can use the output below as a guide. Please enter the first number: 4 Please enter the second number: 2 Please enter the third number: 9 The sum of the three numbers is: 15.

In: Computer Science

Discuss and gather insight and feedback on the importance of data models and how to discover...

Discuss and gather insight and feedback on the importance of data models and how to discover business rules and interpret them as an information resource.

In: Computer Science