Questions
For this part of the assignment I want you to execute the script CS50_hw_session04b. This will...

For this part of the assignment I want you to execute the script CS50_hw_session04b. This will create a directory called hw_session04 in your home directory. Change directories to hw_session04.

- Execute file_1 in hw_session04

- Read file_2 in hw_session04

- Create the file dir_3/name with the output of the whoami command and the first secret code when you execute file_1. Save the output of executing file_1 exactly as shown. There should be two lines in dir_3/name.

- Create the file dir_3/now with the output of the date command and the second secret code when you read file_2. Save the output of reading file_2 exactly as shown. There should be two lines in dir_3/now.
- Create a file called jamesbond in hw_session04 with the output of the date command. Change the permissions of the file jamesbond so that user has no access, group has no access but other has full access.

- Create a file called myfriend in hw_session04 with the output of the date command. Change the permissions of the file myfriend so that user has full access, group has read and execute access and other has no access.

- Execute the following commands and add the output to a file call session04b_hw

--- Echo your first and last name as the first line of the file session04b_hw
--- Get a long listing of the files in hw_session04
--- Display the contents of the file dir_3/name
--- Display the contents of the file dir_3/now
--- Echo the following message "The permissions of jamesbond is XXX". When you echo this message replace the XXX with the numeric permission value for the file jamesbond before echoing out the message.

Once you have executed the above commands, look over the file session04b_hw and check that it looks like you would expect based on the commands you have executed.

In: Computer Science

Java program by using array only. II. The NumberTile Game (Unchanged) Number tiles are squares with...

Java program by using array only.

II. The NumberTile Game (Unchanged)

  • Number tiles are squares with a number from 1 to 9 at each side. A “board” for the game is a sequence of number tiles satisfying this property:

      The right side of each tile (except the last) = the left side of the next tile on the board

  • There are 2 players in the game, both of which are the computer. Each player starts with a "hand" of 5 number tiles. A move is made by a player removing tile from the hand and placing it on the board, if possible.   A tile may be placed on the board in any of 3 ways:
  1. As the new first tile
  2. Between two adjacent tiles
  3. As the new last tile
  • A number tile in the players hand can be rotated 90 degrees but once placed on the board its position is fixed
  • If none of the tiles in the hand can be placed on the board, then one random tile is added to the player's hand
  • A round is when player1 makes a move and then player2 makes a move (to make the game fair)
  • The game ends when all tiles are removed from one (or both) player's hand(s). If one player's hand is empty and the other player's hand still contains tiles, then the player with the empty hand is the winner. If both players’ hands are empty, then the game ends in a tie

III. Specifications

  • NEW: The output from 3 games must be written to an output file
  • Your program will consist of the same 5 classes
  • Use the skeletons of the NumberTile, Hand, Board, and TileGame classes provided
  1. Not allow to add or remove or relocate any methods
  2. Not allow to modify any of the method or instance variable declarations or add any new instance variables
  • create two Hand objects
  1. create a TileGame object using the two Hand objects
  2. call the toString() method of the Hand class for each initial hand and print them, properly labeled
  3. call the play() method of the TileGame class
  4. call the getResults() method of the TileGame class and print the string returned
  1. After each game, give the user the option to see another
  2. You must use the counter provided in each class as the upper bound on all loops that traverse the array! (see PartiallyFilled.java, online)
  3. You may use Arrays.copyOf, other Arrays class methods, and System.arraycopy ONLY to resize an array if it becomes full at it’s declared capacity. (If that happens, something’s wrong).
  4. No credit for using Arrays.copyOf or System.arraycopy to place a tile on the Board or remove or insert a tile from/to a Hand

NumberTile.java

import java.util.ArrayList ;
import java.util.Random;

// A NumberTile is a square tile with a number from 1 to 9 on each side
public class NumberTile 
{
    private ArrayList tile ;    // the 4-sided tile
    private static final Random gen = new Random() ;
      
    // Create a NumberTile object with 4 random ints in the range 1 to 9
    public NumberTile() 
    {
       // TO DO: Code the body of this method
    }
    
    // Rotate this NumberTile 90 degrees
    public void rotate() 
    {
       // TO DO: Code the body of this method
    }
    
    // Return the number on the left side of this NumberTile
    public int getLeft()
    {
        // Do NOT modify this method
        return tile.get(0) ;
    }
    
    // Return the number on the right side of this NumberTile
    public int getRight() 
    {
        // Do NOT modify this method
        return tile.get(2) ;
    }
    
    // Return this NumberTile as a multiline string in the form:
    //     9
    //  3     7
    //     6
    //
    public String toString() 
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return null ;
    }    
} // end of NumberTile class

Hand.java

import java.util.ArrayList;

// A player's hand of NumberTiles
public class Hand
{
    private ArrayList hand ;
    private final static int INITIAL_SIZE = 5 ;  // starting hand size
    
    // Creates a new hand of INITIAL_SIZE NumberTiles 
    public Hand()
    {
       // TO DO: Code the body of this method
    }
       
    // Get the NumberTile at the specified index in this Hand
    public NumberTile get(int index)
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return null ;
    }
    
    // Get the number of tiles in this Hand
    public int getSize()
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return -999 ;
    }
    
    // Add a new NumberTile to this Hand
    public void addTile()
    {
       // TO DO: Code the body of this method
    }
    
    // Remove the NumberTile at the specified index from this Hand
    public void removeTile(int index)
    {
        // TO DO: Code the body of this method
    }
    
    // Is this hand empty?
    public boolean isEmpty()
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return false ;
    }
    
    // Return this Hand as a multiline String.
    // If this Hand is empty, return an appropriate message
    public String toString()
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return "The hand" ;
    }
}
Board.java

import java.util.ArrayList;

// The board for the NumberTile game  
public class Board
{
    private ArrayList board ;    // the board for a NumberTile game
    
    // Creates a new Board containing a single NumberTile
    public Board()
    {
       // TO DO: Code the body of this method       
    }
    
    // Return the NumberTile at the specified index on this Board
    public NumberTile getTile (int index)
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return null ;   
    }
    
    // Return the current number of tiles on this Board
    public int getSize()
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return -999 ;
    }
    
    // Insert a new tile into this Board at the specified index
    public void addTile(int index, NumberTile tile)
    {
       // TO DO: Code the body of this method
    }
    
    // Return a multiline string containing all the tiles on this Board
    public String toString()
    {
       // TO DO: Code the body of this method
       
       // temporary return statement so program skeleton will compile and run
       return "The board" ;
    }           
}

TileGame.java

// Implements a domino-like game where two players, both of whom are
// the computer, take turns inserting NumberTiles into a Board
public class TileGame
{
   // instance vars
   private Board board ;     // the game board
   private Hand hand1 ;      // Player 1 hand
   private Hand hand2 ;      // Player 2 hand
   private String winner ;   // the winner - player1, player2,
                             // or a tie game
   
   // Creates a new TileGame with two initial hands and a board
   public TileGame(Hand firstHand, Hand secondHand)
   {
      // TO DO: Code the body of this method
   }
   
   // Players take turn moving until one or both hand are empty
   public void play()
   {
      // TO DO: Code the body of this method
   }

   // Utility method called by method makeMove.  Returns the index at which a
   // new tile will be inserted into the board, or -1 if the tile cannot
   // be inserted.  The new tile may be inserted either (1) between two 
   // existing tiles, (2) as the new first tile, or (3) as the new last tile
   private int getIndexForFit(NumberTile tile)
   {
      // TO DO: Code the body of this method
       
      // temporary return statement so program skeleton will compile and run
      return -1 ;
   }

   // Utility method called by method play().  Checks consecutive tiles in the 
   // hand - by calling method getIndexForFit() - to see if one can be inserted 
   // into the board. When the first tile that fits is found, removes it from
   // the hand, inserts it into the board, and the move ends.  The tile may be
   // rotated up to 3 times. If none of the tiles fit, adds a new, random tile
   // to the hand  
   private void makeMove(Hand hand)
   {
      // TO DO: Code the body of this method
   }
   
   // Return results of the game as a humongous multi-line String containing
   // the final board, both both player's final hands, and the winner
   public String getResults()
   {
      // TO DO: Code the body of this method
      // HINT: call toString for the board and for each hand and don't
      //       forget the winner
       
      // temporary return statement so program skeleton will compile and run
      return "Results" ;
   }
} // end of TileGame2 class

TileGameTester.java

// A test class for the NumberTile Game
public class TileGameTester
{
   public static void main(String[] args)
   {
      // TO DO: Code the body of this method
   }
} 

Basically, we will have 5 tiles on our hands. If tiles contain a number of the left/right number on board. We can place it on board.

Board:

5

4 6

2

so that we need to have 4/6 on our hand. if so, we can rotate the number for that tile and put it out.

4 2

2 5 ==> 6 4

6 5

TO board:

2

6 4

5

5

4 6

2

Starting a new game...

***** Player 1 Initial Hand *****

    7

5   7

    6

    4

1   1

    9

    2

2   6

    2

    9

7   7

    1

    9

6   5

    3

***** Player 2 Initial Hand *****

    7

6   2

    1

    8

2   8

    3

    9

2   4

    2

    1

9   6

    3

    9

2   3

    1

***** The Initial Board *****

    5

3   4

    1

***** The Final Board *****

    8

8   3

    2

    5

3   4

    1

    1

4   9

    1

    7

9   1

    7

    6

1   7

    2

    6

7   5

    7

    3

5   6

    9

    2

6   2

    2

    2

  2   9

    4

In: Computer Science

Given an array of positive integers except one negative integer. Develop a divide-conquer algorithm to find...

Given an array of positive integers except one negative integer. Develop a divide-conquer algorithm to find the index of the negative integer, and compute its average complexity.

Please provide a solution in Java

In: Computer Science

Decimal value data types such as float and double represent the decimal number as an approximation....

Decimal value data types such as float and double represent the decimal number as an approximation. In other words, float or double arithmetic do not give exact answer but near approximation to the answer. As an example, run the following program and check its result:
#include <iostream>
using namespace std;
int main()
{
float x= 0.1 * 7;
if (x == 0.7)
cout<< "TRUE. \n";
else
cout<< "FALSE. \n";
return 0;
}
In some situations, we need our programs to give exact solutions instead of near to exact answers. Some programming languages provide a special data type called Decimal that represents decimal numbers without the use of approximation. Write a program in C++ that implements the Decimal data type using a class called BigDecimal. This class will allow users to create decimal values and perform several operations on these values. The class should use two member variables:
- the integer part saved as a string
- the decimal part saved as a string
For example, the following instance BigDecimal d("6.45678"); will store "6" in the first variable and "45678" in the second variable
The class should have the following functionalities:
Member Function Description
BigDecimal() The default constructor. Creates the number 0.0
BigDecimal(string) A constructor that accepts a string representing the numeric value with the decimal point.
== operator Accepts two BigDecimal values and compares their values. If the two decimal values are equal then the method should return true otherwise it should return false.
!= operator Accepts two BigDecimal values and compares their values. If the two decimal values are equal then the method should return false otherwise it should return true.
++ operator (prefix) This operator should increment the integer part of BigDecimal object by one. The overloaded ++ operator should return the contents of the object (using this pointer) after it is incremented.
++ operator (postfix) This operator should increment the integer part of BigDecimal object by one. The overloaded ++ operator should return the contents of the object before it is incremented.
<< operator Displays the numeric value of BigDecimal to the standard output.
>> operator Reads a string value from the standard input and stores it in the BigDecimal object.
double toDouble() Converts the BigDecimal value to a double.
You can assume that all the values of BigDecimal are nonnegative. Here is an example of how BigDecimal can be used:
BigDecimal x("45.67");
BigDecimal y("2.5");
//Should print 2.5
cout << x++ << endl;
//Should print 4.5
cout << ++x << endl;
//Should print false
cout << x==y << endl;

In: Computer Science

How can user error be controlled? Is it unavoidable?

How can user error be controlled? Is it unavoidable?

In: Computer Science

I am coding in MySQL and two of my tables are populating find but the other...

I am coding in MySQL and two of my tables are populating find but the other two "Employee" and "Assignment" won't. I keep getting an error code saying I can't alter a child table and I can't figure out what to fix. Here is my code:

CREATE TABLE DEPARTMENT (

DepartmentName Char(35) NOT NULL,

BudgetCode Char(30) NOT NULL,

OfficeNumber Char(15) Not Null,

DepartmentPhone Char(12) NOT NULL,

CONSTRAINT DEPARTMENT_PK primary key(DepartmentName)

);

CREATE TABLE EMPLOYEE(

EmployeeNumber Int NOT NULL AUTO_INCREMENT,

FirstName Char(25) NOT NULL,

LastName Char(25) NOT NULL,

Department Char(35) NOT NULL DEFAULT 'Human Resources',

Position Char(35) NULL,

Supervisor Int NULL,

OfficePhone Char(12) NULL,

EmailAddress VarChar(100) NOT NULL UNIQUE,

CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeNumber),

CONSTRAINT EMP_DEPART_FK FOREIGN KEY(Department)

REFERENCES DEPARTMENT(DepartmentName)

ON UPDATE CASCADE,

CONSTRAINT EMP_SUPER_FK FOREIGN KEY(Supervisor)

REFERENCES EMPLOYEE(EmployeeNumber)

);

ALTER TABLE EMPLOYEE AUTO_INCREMENT=1;



CREATE TABLE PROJECT(

ProjectID Int NOT NULL AUTO_INCREMENT,

ProjectName Char(50) NOT NULL,

Department Char(35) NOT NULL,

MaxHours Numeric(8,2) NOT NULL DEFAULT 100,

StartDate Date NULL,

EndDate Date NULL,

CONSTRAINT PROJECT_PK PRIMARY KEY(ProjectID),

CONSTRAINT PROJ_DEPART_FK FOREIGN KEY(Department)

REFERENCES DEPARTMENT(DepartmentName)

ON UPDATE CASCADE

);

ALTER TABLE PROJECT AUTO_INCREMENT=1000;

CREATE TABLE ASSIGNMENT (

ProjectID Int NOT NULL,

EmployeeNumber Int NOT NULL,

HoursWorked Numeric(6,2) NULL,

CONSTRAINT ASSIGNMENT_PK PRIMARY KEY(ProjectID, EmployeeNumber),

CONSTRAINT ASSIGN_PROJ_FK FOREIGN KEY(ProjectID)

REFERENCES PROJECT(ProjectID)

ON UPDATE NO ACTION

ON DELETE CASCADE,

CONSTRAINT ASSIGN_EMP_FK FOREIGN KEY(EmployeeNumber)

REFERENCES EMPLOYEE(EmployeeNumber)

ON UPDATE NO ACTION

ON DELETE NO ACTION

);

INSERT Department(DepartmentName, BudgetCode, OfficeNumber, DepartmentPhone)

VALUES('Administration', 'BC-100-10', 'BLDG01-201', '360-285-8100'),

('LEGAL', 'BC-200-10', 'BLDG01-220', '360-285-8200'),

('Human Resources', 'BC-300-10', 'BLDG01-230', '360-285-8300'),

('Finance', 'BC-400-10', 'BLDG01-110', '360-285-8400'),

('Accounting', 'BC-500-10', 'BLDG01-120', '360-285-8405'),

('Sales and Marketing','BC-600-10', 'BLDG01-250', '360-285-8500'),

('InfoSysems', 'BC-700-10', 'BLDG02-210', '360-285-8600'),

('Research and Development', 'BC-800-10', 'BLDG02-250', '360-285-8700'),

('Production', 'BC-900-10', 'BLDG02-110', '360-285-8800')

INSERT Employee(EmployeeNumber, FirstName, LastName, Department, Position, Supervisor, OfficePhone, EmailAddress)

VALUES('1', 'Mary', 'Jacobs', 'Administration', 'CEO', NULL, '360-285-8110', '[email protected]'),

('2', 'Rosalie', 'Jackson', 'Administration', 'AdminAsst', '1', '360-825-8120', '[email protected]'),

('3', 'Richard', 'Bandalone', 'Legal', 'Attorney', '1', '360-285-8210', '[email protected]'),

('4', 'George', 'Smith', 'Human Resources', 'HR3', '1', '360-285-8310', '[email protected]'),

('5','Alan', 'Adams', 'Human Resources', 'HR1', '4', '360-285-8320', '[email protected]'),

('6', 'Ken', 'Evans', 'Finance', 'CFO', '1', '360-285-8410', '[email protected]'),

('7', 'Mary', 'Abernathy', 'Finance', 'FA3', '6', '360-285-8420', '[email protected]'),

('8', 'Tom', 'Caruthers', 'Accounting', 'FA2', '6', '360-285-8430', '[email protected]'),

('9', 'Heather', 'Jones', 'Accounting', 'FA2', '6', '360-825-8440', '[email protected]'),

('10', 'Ken', 'Numoto', 'Sales and Marketing', 'SM3', '1', '360-285-8510', '[email protected]'),

('11', 'Linda', 'Granger', 'Sales and Marketing', 'SM3', '10', '360-285-8520', '[email protected]'),

('12', 'James', 'Nestor', 'InfoSystems', 'CIO', '1', '360-285-8610', '[email protected]'),

('13', 'Rick', 'Brown', 'InfoSystems', 'IS2', '12', NULL, '[email protected]'),

('14', 'Mike', 'Nguyen', 'Research and Development', 'CTO', '1', '360-285-8710', '[email protected]'),

('15', 'Jason', 'Sleeman', 'Research and Development', 'RD3', '14', '360-285-8720', '[email protected]'),

('16', 'Mary', 'Smith', 'Production', 'OPS3', '1', '360-825-8810', '[email protected]'),

('17', 'Tom', 'Jackson', 'Production', 'OPS2', '16', '360-825-8820', '[email protected]'),

('18', 'George', 'Jones', 'Production', 'CPS2', '17', '360-825-8830', '[email protected]'),

('19', 'Julia', 'Hayakawa', 'Production', 'CPS1', '17', NULL, '[email protected]'),

('20', 'Sam', 'Stewart', 'Production', 'OPS1', '17', NULL, '[email protected]')

INSERT Project(ProjectID, ProjectName, Department, MAxHours, StartDate, EndDate)

VALUES ('1000', '2017 Q3 Production Plan', 'Production', '100.00', '05/10/17', '2017-06-15'),

('1100', '2017 Q3 Marketing Plan', 'Sales and Marketing', '135.00', '05/10/17', '2017-06-15'),

('1200', '2017 Q3 Portfolio Analysis', 'Finance', '120.00', '07/05/17', '2017-07-25'),

('1300', '2017 Q3 Tax Preparation', 'Accounting', '145.00', '08/10/17', '2017-10-15'),

('1400', '2017 Q4 Production Plan', 'Production', '100.00', '08/10/17', '2017-09-15'),

('1500', '2017 Q4 Marketing Plan', 'Sales and Marketing', '135.00', '08/10/17', '2017-09-15'),

('1600', '2017 Q4 Portfolio Analysis', 'Finance', '140.00', '10/05/17', NULL)








INSERT Assignment(ProjectID, EmployeeNumber, HoursWorked)

VALUES('1000', '1', '30.00'),

('1000', '6', '50.00'),

('1000', '10', '50.00'),

('1000', '16', '75.00'),

('1000', '17', '75.00'),

('1100', '1', '30.00'),

('1100', '6', '75.00'),

('1100', '10', '55.00'),

('1100', '11', '55.00'),

('1200', '3', '20.00'),

('1200', '6', '40.00'),

('1200', '7', '45.00'),

('1200', '8', '45.00'),

('1300', '3', '25.00'),

('1300', '6', '40.00'),

('1300', '8', '50.00'),

('1300', '9', '50.00'),

('1400', '1', '30.00'),

('1400', '6', '50.00'),

('1400', '10', '50.00')



In: Computer Science

Write a program that implements the pseudocode ("informal high-level description of the operating principle of a...

Write a program that implements the pseudocode ("informal high-level description of the operating principle of a computer program or other algorithm") below:
1. Ask the user for the size of their apartment in square meters (size)
2. Convert the size to square feet using the formula: convertedSize = size * 10.764
3. Print out the converted size.

Have meaningful prompts and meaningful explanation of any numbers printed.

In: Computer Science

Hi I am getting error in implement some test case using Java. I am adding my...

Hi I am getting error in implement some test case using Java. I am adding my code and relevant files here, and the failed test. Please let me know where my problem is occuring and fix my code. Thanks! I will upvote.

Implement a class to perform windowing of a Hounsfield value

Implement the class described by this API. A partial implementation is provided for you in the eclipse project; however, unlike the previous class, very little work has been done for you. You must carefully study the API of the class to determine the precise signatures of the constructors and methods that you need to implement. Furthermore, you need to thoroughly understand the concept of windowing to determine what fields are required in your class.

  1. Begin by deciding how many fields are required and what their types should be. Add these fields to your class (making sure that they each have a private access modifier) giving them a sensible name when you do so.
  2. Once you have added the fields to your class, implement the methods getLevel and getWidth. The JUnit tester requires these methods to test the constructors and other methods.
  3. Implement the constructor HounsfieldWindow(int level, int width) first. Make sure that it has the correct access modifier and signature.
  4. Implement the no-argument constructor HounsfieldWindow() next. Use constructor chaining to implement this constructor.
  5. Implement the remaining methods making sure that they each have the correct access modifier, signature, and return type.

Remember to run the JUnit tester each time you complete a constructor or method, and to carefully study the result of the tests to help you through the development process.

API doc: https://drive.google.com/open?id=1GKm_m74PwFBZIC__JmnWnGi6cFzmGuul

/**
* A class that represents a windowed view of Hounsfield units. A Hounsfield
* window is defined by two values: (1) the window level, and (2) the window
* width. The window level is the Hounsfield unit value that the window is
* centered on. The window width is the range of Hounsfield unit values that the
* window is focused on.
*
*


* A window has a lower and upper bound. The lower bound is defined as the
* window level minus half the window width:
*
*


* lo = level - (width / 2)
*
*


* The upper bound is defined as the window level plus half the window width:
*
*


* hi = level + (width / 2)
*
*


* Hounsfield units are mapped by the window to a real number in the range of
* {@code 0} to {@code 1}. A Hounsfield unit with a value less than lo is mapped
* to the value {@code 0}. A Hounsfield unit with a value greater than hi is
* mapped to the value {@code 1}. A Hounsfield unit with a value v between lo
* and hi is mapped to the value:
*
*


* (v - lo) / width
*
*
*/
public class HounsfieldWindow {
  
   private int level;
  
   private int width;
  
  
   HounsfieldWindow(int level, int width) {
       setLevel(level);
       this.width = width;
   }
  
   public HounsfieldWindow() {
       this(0, 400);
   }
   public int getLevel() {
       return level;
   }
  
   public int setLevel(int level) {
       if (level < Hounsfield.MIN_VALUE || level > Hounsfield.MAX_VALUE) {
           throw new IllegalArgumentException();
       }
       int data = this.level;
       this.level = level;
       return data;
   }
  
   public int getWidth() {
       return width;
   }
  
   public int setWidth(int width) {
       if(width < 1) {
           throw new IllegalArgumentException();
       }
       int data = this.width;
       this.width = width;
       return data;
  
      
   }
  
   public double getLowerBound() {
       return level - (width / 2);
   }
   public double getUpperBound() {
   return level + (width / 2);
   }

   public double map(Hounsfield h) {
       // TODO Auto-generated method stub
       int hounsfieldUnitVal = h.get();
   System.out.println("got " + hounsfieldUnitVal);
   if(hounsfieldUnitVal < getLowerBound()) {
   return 0;
   }
   if(hounsfieldUnitVal > getUpperBound()) {
   return 1;
   }
   return (hounsfieldUnitVal - getLowerBound()) / (double)width;
   }

  
  
  
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Tests that fails:

@Test
   public void test04_ctorThrowsOnBadWidth() {
       final int[] BAD_WIDTHS = {-10000, -10, 0};
       for (int width : BAD_WIDTHS) {
           try {
               new HounsfieldWindow(0, width);
               fail(String.format("new HounsfieldWindow(0, %s) should throw an exception", width));
           }
           catch (IllegalArgumentException x) {
               // ok
           }
       }
   }

@Test
   public void test10_map() {
       assumeTrue("test requires a correct implementation of HounsfieldWindow(int, int)", IS_CTOR_OK);
      
       // uses windows of width 1
       // easy to test because map should always return 0.5 for
       // Hounsfield values inside the window
       final int width = 1;

       for (int level = Hounsfield.MIN_VALUE; level <= Hounsfield.MAX_VALUE; level++) {
           // make a window to call map on
           HounsfieldWindow w = new HounsfieldWindow(level, width);

           // the actual value returned by map
           double got = w.map(new Hounsfield(level));

           // make an error message in case the test fails
           String error = String.format(
                   "map(%s) failed to return the correct value for a window with level %s, width %s", level, level,
                   width);

           // assert that 0.5 equals got
           assertEquals(error, 0.5, got, 1e-9);
       }
   }

@Test
   public void test11_map() {
       assumeTrue("test requires a correct implementation of HounsfieldWindow(int, int)", IS_CTOR_OK);
      
       // tests Hounsfield units in windows of various widths and levels
       final int[] WIDTH = {2, 3, 4, 5, 10, 25, 50, 75, 100, 255};
       final int[] LEVEL = {-800, -1, 1, 750};
      
       for (int level : LEVEL) {
           for (int width : WIDTH) {
               // make a window to call map on
               HounsfieldWindow w = new HounsfieldWindow(level, width);
              
               // expected values map should return
               double[] EXP = HounsfieldWindowTest.mapValues(width);
              
               for (int i = 0; i < EXP.length; i++) {
                   // Hounsfield unit to map
                   Hounsfield h = new Hounsfield(level - width / 2 + i);
                  
                   // the expected return value of map(h)
                   double exp = EXP[i];
                  
                   // the actual value returned by map(h)
                   double got = w.map(h);
                  
                   // make an error message in case the test fails
                   String error = String.format(
                           "map(%s) failed to return the correct value for a window with level %s, width %s", h.get(), level,
                           width);

                   // assert that exp equals got
                   assertEquals(error, exp, got, 1e-9);
               }
           }
       }
   }

Relevant files(Hounsfield.java and Hounsfieldtest.java): https://drive.google.com/open?id=1HRUH5bika5xeLO7G_kP2LeMxNeXejRgl

In: Computer Science

Write a C program to calculate the number of fence panels needed over a given distance....

Write a C program to calculate the number of fence panels needed over a given distance. The fence must be created using two difference size panels which have a 2 foot length difference between them (ie. panels could be 2’ and 4’ or 3’ and 5’ or 5’and 7’). Your program should request the total length of the fence and the smaller panel's size. Your program will then calculate the length of the larger panel and output the number of each size panel necessary for the given length of fence. If there is a length of fence that is different from the two panel sizes, you should consider that to be a special size panel that is necessary to complete the length of fence. Output the length of that special panel. The examples below show different inputs and the expected outputs.

Here is an example of running your program with different inputs.
NOTE: Bold text represents input that someone will type into your program.

Measurement of the fencing needed (feet): 50
Enter the size of smaller panel in feet: 3
The larger panel will be 5 feet.

Happy Building!!

The fence will need 6 qty 3 foot panel(s) and 6 qty 5 foot panel(s).
Plus a special order 2 foot panel.

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

Measurement of the fencing needed (feet): 50
Enter the size of smaller panel in feet: 4
The larger panel will be 6 feet.

Happy Building!!

The fence will need 5 qty 4 foot panel(s) and 5 qty 6 foot panel(s).

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

Measurement of the fencing needed (feet): 2
Enter the size of smaller panel in feet: 1
The larger panel will be 3 feet.

Happy Building!!

The fence will need 2 qty 1 foot panel(s) and 0 qty 3 foot panel(s).

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

Measurement of the fencing needed (feet): 52
Enter the size of smaller panel in feet: 3
The larger panel will be 5 feet.

Happy Building!!

The fence will need 7 qty 3 foot panel(s) and 6 qty 5 foot panel(s).
Plus a special order 2 foot panel.

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

Measurement of the fencing needed (feet): 0
Please enter an integer > 0: 54
Enter the size of smaller panel in feet: -34
Please enter an integer > 0: 4
The larger panel will be 6 feet.

Happy Building!!

The fence will need 6 qty 4 foot panel(s) and 5 qty 6 foot panel(s).

In: Computer Science

1.)recursive merge sort on a list.(Python) 2.)recursive bubble sort using a list without enumerate() function.(python) Show...

1.)recursive merge sort on a list.(Python)

2.)recursive bubble sort using a list without enumerate() function.(python)

Show Base case, and recursive case.

In: Computer Science

the following has differing roles within a large IT department in the development of a new...

the following has differing roles within a large IT department in the development of a new computer system. define these roles and responsibilities;
1. project manager
2. technical manager
3. database administrator

In: Computer Science

Bank Linked List Project: Create a bank linked list project program to mimic a simple bank...

Bank Linked List Project:
Create a bank linked list project program to mimic a simple bank account system (open account, deposit, withdraw, loans etc.).
Requirements:
1. Use linked list (queues and/or stacks)
2. Classes
3. Arrays
4. Add, delete, remove, search methods

(use Dev. C++ to create the program)

In: Computer Science

Simple Java class. Create a class Sportscar that inherits from the Car class includes the following:...

Simple Java class.

Create a class Sportscar that inherits from the Car class includes the following:

a variable roof that holds type of roof (ex: convertible, hard-top,softtop)

a variable doors that holds the car's number of doors(ex: 2,4)

implement the changespeed method to add 20 to the speed each time its called

add exception handling to the changespeed method to keep soeed under 65

implement the sound method to print "brooom" to the screen.

create one constructor that accepts the car's roof,doors, year, and make as arguments and assigns the values appropriately. do not create any other constructors.

the interface methods should print messages using system.out.println()

car class:

abstract clas Car implements Vehicle(

private int year;

private int speed;

private string make;

private static int count=0;

public car(int year, string amake){

year = aYaer;

make = aMake;

speed =0;

count++;}

public void sound();

public static int getcount90{

return count;}

}

In: Computer Science

Improving community street lighting using CPTED: A case study of communities in the United States. Why...

Improving community street lighting using CPTED: A case study of communities in the United States.
Why is Street lighting so important?
Please cite two sources
Length: 2-3 paragraphs

In: Computer Science

What is the exact output of the following pseudocode segment? METHOD MAIN CALL myMethod (0,2) CALL...

What is the exact output of the following pseudocode segment?

METHOD MAIN

CALL myMethod (0,2)
CALL myMethod (3,5)

CALL myMethod (6,7)  

END MAIN

Answer:

METHOD myMethod(A,B)
BEGIN
    WHILE (A < B)
         PRINT(A + " ")
         A ← A + 1
    ENDWHILE
    PRINTLINE();

END MyMethod

In: Computer Science