Questions
This project involves writing a program to simulate a blackjack card game. You will use a...

This project involves writing a program to simulate a blackjack card game. You will use a simple console-based user interface to implement this game. A simple blackjack card game consists of a player and a dealer. A player is provided with a sum of money with which to play. A player can place a bet between $0 and the amount of money the player has. A player is dealt cards, called a hand. Each card in the hand has a point value. The objective of the game is to get as close to 21 points as possible without exceeding 21 points. A player that goes over is out of the game. The dealer deals cards to itself and a player. The dealer must play by slightly different rules than a player, and the dealer does not place bets. A game proceeds as follows: A player is dealt two cards face up. If the point total is exactly 21 the player wins immediately. If the total is not 21, the dealer is dealt two cards, one face up and one face down. A player then determines whether to ask the dealer for another card (called a “hit”) or to “stay” with his/her current hand. A player may ask for several “hits.” When a player decides to “stay” the dealer begins to play. If the dealer has 21 it immediately wins the game. Otherwise, the dealer must take “hits” until the total points in its hand is 17 or over, at which point the dealer must “stay.” If the dealer goes over 21 while taking “hits” the game is over and the player wins. If the dealer’s points total exactly 21, the dealer wins immediately. When the dealer and player have finished playing their hands, the one with the highest point total is the winner. Play is repeated until the player decides to quit or runs out of money to bet. You must use an object-oriented solution for implementing this game.

Each public class must be contained in a separate Java source file. Only one source file will have a main() method and this source will be named BlackjackGameSimulator.java. Other source/class names are up to you following the guidelines specified so far in the course. The format of the Java source must meet the general Java coding style guidelines discussed so far during the course. Pay special attention to naming guidelines, use of appropriate variable names and types, variable scope (public, private, protected, etc.), indentation, and comments. Classes and methods should be commented with JavaDoc-style comments (see below). Please use course office hours or contact the instructor directly if there are any coding style questions. JavaDocs: Sources should be commented using JavaDoc-style comments for classes and methods. Each class should have a short comment on what it represents and use the @author annotation. Methods should have a short (usually 1 short sentence) description of what the results are of calling it. Parameters and returns should be documented with the @param and @return annotations respectively with a short comment on each. JavaDocs must be generated against every project Java source file. They should be generated with a - private option (to document all protection-level classes) and a –d [dir] option to place the resulting files in a javadocs directory/folder at the same level as your source files.

In: Computer Science

Implementation of Quick sort and heap sorting algorithms in C++

Implementation of Quick sort and heap sorting algorithms in C++

In: Computer Science

When should you use the String Class as opposed to the StringBuilder Class? Describe why this...

When should you use the String Class as opposed to the StringBuilder Class? Describe why this answer is logical.

In: Computer Science

Using the python program language. Expand/EDIT the code below for all vowels (AEIOU). Please provide a...

Using the python program language. Expand/EDIT the code below for all vowels (AEIOU). Please provide a code and a screen shot of the code working with an output. the code should be able to take any name as an  input. The code should be able to pull out the vowels along with the count fo each vowel within that name for the output.

#countVowels.py
import sys

s1 = str(sys.argv[1])
(a,e,i,o,u) = (0,0,0,0,0)
print ("String length = ", len(s1))
for n in range(0, len(s1)):
if (s1[n] == 'a'):
a += 1
elif s1[n] == 'e':
e += 1

print ("a count = ", a)
print ("e count = ", e)
c = len(s1) - a - e
print ("Consonants count ", c)

In: Computer Science

Our Client, a renowned trading company, suffered a sudden, devastating power outage that caused their server...

Our Client, a renowned trading company, suffered a sudden, devastating power outage that caused their server to cease functioning. The company took the hard-drive to a local computer repair company that was unable to read the corrupt drive. At this point, the company contacted you, a forensics consultant, to recover the information. What actions will you take? Provide 5 specific steps and explain how these actions will help.

In: Computer Science

Answer the questions in full 1: What field in the IP header can be used to...

Answer the questions in full

1: What field in the IP header can be used to ensure that a packet is forwarded through no more than N routers?

2: Do routers have IP addresses? If so, how many?

3: Suppose you wanted to implement a new routing protocol in the SDN control plane. At which layer would you implement the protocol? Explain

In: Computer Science

python: Implement a function that reverses a list of elements by pushing them onto a stack...

python: Implement a function that reverses a list of elements by pushing them onto

a stack in one order, and writing them back to the list in reversed order.

In: Computer Science

Write a Java program that implements a queue in a hospital. I want your program to...

Write a Java program that implements a queue in a hospital. I want your program to ask the user to enter the number of patients then enter the patient number starting from 110 till the end of the queue then print number of patients waiting in the queue.

Suppose you have a queue D containing the numbers (1,2,3,4,5,6,7,8), in this order. Suppose further that you have an initially empty Stack S. Give a code fragment that uses S, to store the elements in the order (8,7,6,5,4,3,2,1) in D.

In: Computer Science

Define a problem with user input, user output, Switch and some mathematical computation. Write the pseudocode,...

Define a problem with user input, user output, Switch and some mathematical computation. Write the pseudocode, code and display output.

Include source code and output. If no output explain the reason why and what you are going to do make sure it does not happen again aka learning from your mistakes.

Problem:
Pseudocode:
Code:
Output:

In: Computer Science

Question 1:Write a program that randomly generates 100 dates and store them into a vector. Use...

Question 1:Write a program that randomly generates 100 dates and store them into a vector. Use the Date class provided . The dates generated must be within 1000 days after 1/1/2000.
Question 2:Sort the 100 dates generated in Question 1 in ascending order.

This is Class data.h.(Please don't change the data.h file)

data.h

#ifndef DATE_H_
#define DATE_H_

#include
#include

using namespace std;

class Date {
   friend ostream &operator<<( ostream &, const Date & );
private:
   int day;
   int month;
   int year;
static const int days[]; // array of days per month
void helpIncrement(); // utility function for incrementing date

public:
   Date(int=1, int=1, int=0);
   void setDate(int,int,int);
   bool leapYear( int ) const; // is date in a leap year?
bool endOfMonth( int ) const; // is date at the end of month?
Date &operator++(); // prefix increment operator
Date operator++( int ); // postfix increment operator
const Date &operator+=( int ); // add days, modify object
bool operator<(const Date&) const;

   void showdate();
};

const int Date::days[] =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

Date::Date(int d, int m, int y) {
day = d;
month = m;
year = y;
// initialize static member at file scope; one classwide copy
}

// set month, day and year
void Date::setDate( int dd, int mm, int yy )
{
year = yy;
month = ( mm >= 1 && mm <= 12 )? mm : 1;

// test for a leap year
if ( month == 2 && leapYear( year ) )
day = ( dd >= 1 && dd <= 29 ) ? dd : 1;
else
day = ( dd >= 1 && dd <= days[ month ] ) ? dd : 1;
} // end function setDate

// if the year is a leap year, return true; otherwise, return false
bool Date::leapYear( int testYear ) const
{
if ( testYear % 400 == 0 ||
( testYear % 100 != 0 && testYear % 4 == 0 ) )
return true; // a leap year
else
return false; // not a leap year
} // end function leapYear

// determine whether the day is the last day of the month
bool Date::endOfMonth( int testDay ) const
{
if ( month == 2 && leapYear( year ) )
return testDay == 29; // last day of Feb. in leap year
else
return testDay == days[ month ];
} // end function endOfMonth

// function to help increment the date
void Date::helpIncrement()
{
// day is not end of month
if ( !endOfMonth( day ) )
day++; // increment day
else
if ( month < 12 ) // day is end of month and month < 12
{
month++; // increment month
day = 1; // first day of new month
} // end if
else // last day of year
{
year++; // increment year
month = 1; // first month of new year
day = 1; // first day of new month
} // end else
} // end function helpIncrement

// overloaded prefix increment operator
Date &Date::operator++()
{
helpIncrement(); // increment date
return *this; // reference return to create an lvalue
} // end function operator++

// overloaded postfix increment operator; note that the
// dummy integer parameter does not have a parameter name
Date Date::operator++( int )
{
Date temp = *this; // hold current state of object
helpIncrement();

// return unincremented, saved, temporary object
return temp; // value return; not a reference return
} // end function operator++

// add specified number of days to date
const Date &Date::operator+=( int additionalDays )
{
for ( int i = 0; i < additionalDays; i++ )
helpIncrement();

return *this; // enables cascading
} // end function operator+=

// overloaded output operator
ostream &operator<<( ostream &output, const Date &d )
{
// static string monthName[ 13 ] = { "", "January", "February",
// "March", "April", "May", "June", "July", "August",
// "September", "October", "November", "December" };
//
// output << d.day << " " << monthName[ d.month ] << " "<< d.year;
   output << setfill('0')
           << setw(2) << d.day << '/'
           << setw(2) << d.month << '/'
           << setw(4) << d.year;

   return output; // enables cascading
} // end function operator<<

bool Date::operator<(const Date& right) const {
   return (year < right.year || (year == right.year && month < right.month) ||
           (year == right.year && month == right.month && day < right.day));
}

void Date::showdate()
{
cout << "The date is ";
cout << setfill('0')
       << setw(2) << day << '/'
       << setw(2) << month << '/'
       << setw(2) << year % 100
       << endl;
return;
}

#endif /* DATE_H_ */

In: Computer Science

Write a Python program that will process the text file, Gettysburg.txt, by calculating the total words...

Write a Python program that will process the text file, Gettysburg.txt, by calculating the total words and output the number of occurrences of each word in the file.

The program needs to open the file and process each line. You need to add each word to the dictionary with a frequency of 1 or update the word’s count by 1. You need to print the output from high to low frequency.

The program needs 4 functions.

The first function is called add_word where you add each word to the dictionary. The parameters are the word and a dictionary. There is no return value.

The second function is called Process_line where you strip off various characters, split out the words, and so on. The parameters are a line and a dictionary. It calls the add_word function with each processed word. There is no return value.

The third function is called Pretty_print where this will be the printing function. The parameter is a dictionary. There is no return value.

The fourth function is the main where it will open the file and call Process_line on each line. When finished, it will call the Pretty_print function to print the dictionary.

Gettysburg.txt

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.

Abraham Lincoln
November 19, 1863

In: Computer Science

Can someone please check to see if these are right? If not please explain thank you!...

Can someone please check to see if these are right? If not please explain thank you!

Convert the following decimal numbers to their binary-octet equivalent.

114 = 1110010

254 =11111110

229 =11100101

66 = 01000010

7 =00000111

255 =11111111

192 =11000000

In: Computer Science

I need some asistance understanding of what to do for this problem in javascript: * Problem...

I need some asistance understanding of what to do for this problem in javascript:

* Problem 9 - find the largest number in the list of arguments

*

* Allow any number of arguments to be passed to the function.  Allow both

* String and Number arguments to be passed, but throw an error if any other

* type is passed to the function (e.g., Boolean, Date, etc.). If the list

* is empty (nothing passed to the function), return null.  Otherwise, return

* the largest value that was passed to the function as an argument:

*

* findLargest(1, 2, '3', '4', 5) should return 5

* findLargest('5') should also return 5

* findLargest(5, 3, 2, 1) should also return 5

******************************************************************************/

function findLargest() {

  // Your code here...

}

here are the test cases:

const { findLargest } = require('./solutions');

describe('Problem 9 - findLargest', function() {

  test('should find the largest number in a list', function() {

    let largest = findLargest(1, 2, 3);

    expect(largest).toBe(3);

  });

  test('should find the largest number in a list of 1', function() {

    const largest = findLargest(1);

    expect(largest).toBe(1);

  });

  test('should find the largest number in a long list', function() {

    // https://github.com/gromgit/jstips-xe/blob/master/tips/33.md

    const list = Array.apply(null, { length: 5000 }).map(Function.call, Number);

    const largest = findLargest.apply(null, list);

    expect(largest).toBe(4999);

  });

  test('should work with negative numbers', function() {

    const largest = findLargest(1, 2, 3, -1, -2, -3);

    expect(largest).toBe(3);

  });

  test('should work with strings that are numbers', function() {

    const largest = findLargest('1', '2', '3');

    expect(largest).toBe(3);

  });

  test('should work with decimals', function() {

    const largest = findLargest(0.01, 0.001);

    expect(largest).toBe(0.01);

  });

  test('should throw if a Boolean is included in the list', function() {

    function shouldThrow() {

      findLargest(1, true, 3);

    }

    expect(shouldThrow).toThrow();

  });

  test('should throw if an Object is included in the list', function() {

    function shouldThrow() {

      findLargest(1, console, 3);

    }

    expect(shouldThrow).toThrow();

  });

  test('should throw if a null is included in the list', function() {

    function shouldThrow() {

      findLargest(1, null, 3);

    }

    expect(shouldThrow).toThrow();

  });

  test('should throw if a undefined is included in the list', function() {

    function shouldThrow() {

      findLargest(1, undefined, 3);

    }

    expect(shouldThrow).toThrow();

  });

  test('should return null if the list is empty', function() {

    const largest = findLargest();

    expect(largest).toBe(null);

  });

});

In: Computer Science

Question 2 Consider the one-dimensional data set shown below. x 0.5 3.0 4.5 4.6 4.9 5.2...

Question 2 Consider the one-dimensional data set shown below.

x 0.5 3.0 4.5 4.6 4.9 5.2 5.3 5.5 7.0 9.5
y - - + + + - - + - -

Classify the data point x = 5.0 according to its 1st, 3rd, 5th, and 9th nearest neighbors using K-nearest neighbor classifier.

Question 3 Use data set mushrooms.csv available for developing supervised model. The data set contains two classes namely,edible and poisonous. Perform following analysis on the data set.

Data Set:

1. Understand distribution of classes in the data set using suitable plots.

2. Develop supervised models: Decision tree and k-nearest neighbor

3. Identify best k in Cross-validation evaluating method for supervised models in step 3.

4. Discuss results achieved by each supervised model using confusion matrix, sensitivity, specificity,accuracy, F1-score and ROC curve.

5. Provide your opinion on why there exist variation in performance by models.

In: Computer Science

I have a countdown sequence i have to do for a code, when the result is...

I have a countdown sequence i have to do for a code, when the result is entered it starts to countdown, i tried imputting some codes but i am clueless ( javascript):

/*******************************************************************************

* Problem 3: create count-down number sequence strings

*

* A count-down sequence is a String made up of a descending list of numbers.

* For example, the count-down sequence for the number 3 would be:

*

* "321"

*

* Write the countDownSequence function below, allowing any number between

* 1 and 10 to be accepted.  Otherwise, throw an error (see

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)

*

* If we called countDownSequence(5) we'd expect to get:

*

* "54321"

*

* If we called countDownSequence(55) we'd expect to have an error thrown

*

* Error: only start values between 1 and 10 are valid

*

* @param {Number} start - the number to start counting down from (must be 10 or smaller).

******************************************************************************/

function countDownSequence(start) {

  var ret = '';

  while (start >= 0) {

    ret += start;

    if (start > 0) {

      ret += '';

    }

    start--;

  }

  return ret;

  // Your code here...

}

It has to pass these tests:

const { countDownSequence } = require('./solutions');

describe('Problem 3 - countDownSequence() function', function() {

  test('proper count down sequence from 10', function() {

    let start = 10;

    let result = countDownSequence(start);

    expect(result).toBe('10987654321');

  });

  test('proper count down sequence from 1', function() {

    let start = 1;

    let result = countDownSequence(start);

    expect(result).toBe('1');

  });

  test('starting at 0 should throw', function() {

    function shouldThrow() {

      // Using 0 is invalid, this should throw

      countDownSequence(0);

    }

    expect(shouldThrow).toThrow();

  });

  test('starting at a negative number should throw', function() {

    function shouldThrow() {

      // Using -100 is invalid, this should throw

      countDownSequence(-100);

    }

    expect(shouldThrow).toThrow();

  });

  test('starting at a number greater than 10 should throw', function() {

    function shouldThrow() {

      // Using 11 is invalid, this should throw

      countDownSequence(11);

    }

    expect(shouldThrow).toThrow();

  });

});

In: Computer Science