In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1.
Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people’s eyes glaze over at the first mention of mathematics, your challenge is to write a program that demonstrates the futility of playing the game.
Your program should take as input the amount of money that the player wants to put into the pot, and using a random number generator play the game until the pot is empty. At that point, the program should print:
An example of the program input and output is shown below:
How many dollars do you have? 50 You are broke after 220 rolls. You should have quit after 6 rolls when you had $59.
In: Computer Science
How do you choose the correct graph type? Explain and give examples?
In: Computer Science
Please use Java
You have to write a programing for the following sorting algorithms in increasing order and print required steps in order to explain how your sorting algorithms work.
3. Implement the merge sort algorithm.
With answers in this link (https://www.chegg.com/homework-help/questions-and-answers/write-programing-following-sorting-algorithms-increasing-order-print-required-steps-order--q53916147?trackid=PJ_TOK85), answer the above questions.
In: Computer Science
Do not use arrays and code a program that reads a sequence of positive integers from the keyboard and finds the largest and the smallest of them along with their number of occurrences. The user enters zero to terminate the input. If the user enters a negative number, the program displays an error and continues. Sample 1: Enter numbers: 3 2 6 2 2 6 6 6 5 6 0 Largest Occurrences Smallest Occurrences 6 5 2 3. Do not use arrays and use C++
In: Computer Science
Part I:
Research: Other features of Word are the following Desktop Publishing and pdf files. Why is Desktop Publishing such an important feature of the Word program and cite an example of when you might use Desktop Publishing in your personal or professional life. What are PDF files and why is the feature unique in Word 2019?
Part II: Comment on the following:
Student Success in College Seven Elements of Academic Success.pdf
Actions
In: Computer Science
B. Creation of Program Application (Development Task 1) This program should ask the following questions to determine the number of hotdogs and buns (with minimum number of leftovers) needed for the Annual Hotdog Eating contest:
Assumptions are as follows:
• Hotdogs come in packages of 10.
• Hotdog buns come in packages of 8.
1. The program application should have the following inputs:
• How many people will be competing in the contest?
• How many hotdogs will each person be able to eat?
2. The program application should have the following outputs:
• The minimum number of packages of hotdogs required.
• The minimum number of packages of hotdog buns required.
• The number of hotdogs that will be left over.
• The number of hotdog bunds that will be left over.
3.) Must handle keyboard buffering properly.
4.) Must display proper data formatting of arguments.
5.) Mathematical calculations must be correct
I am writing this in Java
In: Computer Science
Write a console application called PlayingCards that has 4 classes: PlayingCards, Deck, Cards, Card. This application will be able to create a deck of cards, shuffle it, sort it and print it.
Use the following class diagrams to code your application.
Use the following code for the PlayingCards class
public class PlayingCards{ public static void main(String[] args){ System.out.println("Playings Cards"); Deck deck = new Deck(); deck.create(); System.out.println("Sorted cards"); deck.sort(); deck.showCards(); System.out.println("Shuffled cards"); deck.shuffle(); deck.showCards(); } } |
In: Computer Science
Research "Const Correctness" and answer the following questions:
Given:
class SimpleClass { private: int _x; public: SimpleClass(int x) : _x(x){} int getX() const { return _x; } void setX(int newX) { _x = newX; } void displayDataWithCustomMessage(const string &customMessage) { cout<<"Data: "<<_x<<endl; cout<<"Custom Message: "<<customMessage<<endl; } };
In: Computer Science
In this task, you will create a Python script in which you will practice reading files in Python and writing them to a new output file. Construct a text file called Py4_Task3_input.txt that has the following lines:
4
Sandwiches 04 July 2020
Pasta 31 October 2014
Hot Dogs 15 November 2005
Tacos 25 December 1986
The first line of the file represents the number of lines in the data file. Write a loop that reads in each additional line (one line at a time) and stores this line first as a string, then converts it to a list, before moving on to reading the next line. Hint: the string for the second line should be Independence Day 04 July 2021 whereas the list for the second line should be [‘Independence’, ‘Day’, ‘04’, ‘July’, ‘2021’].
Create a second looping structure that outputs each line as a string, then as a list, before moving on to the next line. Name your output file Py4_Task3_output.txt. Name your main program Py4_Task3_teamnumber.py
In: Computer Science
Do not use c-string, arrays, and read input characters one by one. Also use : s.push_back(ch);. Code a program that reads a sequence of characters from the keyboard (one at a time) and creates a string including the distinct characters entered .The input terminates once the user enters a white-space character or the user has entered 50 distinct characters. Eg: Enter a sequence of characters: abAa1121X+&$%$dc[space] Distinct characters are: abA12X+&$%dc. Use C++
In: Computer Science
Please, i need Unique answer, Use your own words (don't copy and paste).
*Please, don't use handwriting.
Suppose you are assigned a task of designing user interface for a web application to get students' feedback about sports facilities provided at the campus. The application is composed of data entry forms with menus and dialog boxes. Having, as goals, speeding up students’ data entry and reducing errors, please tell which six major menu design concerns you will keep in mind during your design process.
In: Computer Science
Consider the following problem:
You are working at the Johnson Center Cinema. The theatre must keep track of the titles and lengths of all movies shown in the theatre. You may assume no two movies will have the same length. The theatre manager wants to know which movie is the shortest, so she can consider offering a discount for the movie. At any given time, the theatre can have up to 5 movies playing. Create an object oriented solution that allows the theatre manager to enter up to 5 movies playing. An error message will display when the manager tries to enter more than 5 movies. Display a summary of all of the movie titles, the number of movies entered, and the title and length of the shortest movie.
To solve this problem, you first create a data definition class (no changes are needed to this class). Copy and paste this code into jGrasp.
public class Movie {
private String title;
private int length;
private static int numMovies = 0;
public Movie() {
this("", 0);
}
public Movie(String title, int length) {
this.title = title;
this.length = length;
++numMovies;
}
public String getTitle() { return this.title;
}
public int getLength() { return this.length;
}
public static int getNumMovies() { return
numMovies; }
public void setTitle(String title) {
this.title = title;
}
public boolean setLength(int length) {
if (length > 0) {
this.length =
length;
return
true;
}
else {
return
false;
}
}
}
Study the incomplete implementation class listed below. Copy and paste this code into jGrasp. Then fill in ONLY the parts where comments suggest code is needed. Do not create/edit code outside of the comment blocks.
import javax.swing.JOptionPane;
public class TheatreIncomplete {
public static void main(String[] args) {
final int NUM_MOVIES = 5;
Movie[] movies = new
Movie[NUM_MOVIES];
int x = 0;
do {
/** START:
BLOCK #1
* In
the block below, enter code that will first check if there is room
to enter another movie in the
*
movies array. If there is, call the add the movie to the array
using the inputMovie() method.
* Else,
if there is not, display an error message to the user letting them
know the maximum nubmer of movies
* that
can be entered.
* Hint:
To check the number of movies already entered, use the
getNumMovies() static method
*/
/** END:
BLOCK #1 **/
}
while
(JOptionPane.showConfirmDialog(null, "Enter another movie?") ==
JOptionPane.YES_OPTION);
Movie shortestMovie =
getShortest(movies);
printSummary(movies,
shortestMovie);
}
private static Movie inputMovie() {
Movie aMovie = new
Movie();
aMovie.setTitle(JOptionPane.showInputDialog(null,
"Enter the title for movie " + Movie.getNumMovies() + ": "));
int length;
boolean isLengthSet =
false;
do {
try {
length
= Integer.parseInt(JOptionPane.showInputDialog("Enter the length of
" + aMovie.getTitle() + " in (minutes)"));
}
catch
(NumberFormatException e) {
length
= -1;
}
isLengthSet =
aMovie.setLength(length);
if
(!isLengthSet) {
JOptionPane.showMessageDialog(null,
"Sorry, you entered an invalid movie length. Please try
again.");
}
} while(!isLengthSet);
return aMovie;
}
private static Movie getShortest(Movie[] movies)
{
Movie aMovie = null;
if (movies.length > 0)
{
/** START:
BLOCK #2
* In
the block below, enter code that will find the movie object
containing the shortest length
* Hint:
You will need to loop through all movies to find the shortest
*/
/** END:
BLOCK #2 **/
}
return aMovie;
}
private static void printSummary(Movie[] movies,
Movie shortestMovie) {
String summary="**Movie
Summary**\n";
/** START: BLOCK #3
* First, using the
summary variable declared above, loop through all of the movies
entered, appending the title of each
* movie to the summary.
Then, append to the summary the number of movies entered, the title
of the shortest movie
* and the length of the
shortest movie
* Hint: To get the number
of movies entered, use the getNumMovies() static method
* Hint: To get the title
and length of the shortest movie, use the object reference passed
into the method
*/
/** END: BLOCK #3 **/
JOptionPane.showMessageDialog(null,
summary);
}
}
In: Computer Science
can you please create the code program in PYTHON for me.
i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this:
if N = 16, matrix is
[ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4]
if N = 64, matrix is
[8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8 -8 8 8 8 8 8 8 8 8 -8 -8 -8
-8 -8 -8 -8 -8 8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8 -8 8 8 8 8 8 8
8 8 -8 -8 -8 -8 -8 -8 -8 -8]
if N = 256, matrix is
[16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 -16 -16 -16 -16
-16 -16 -16 -16 -16 -16 -6 -16 -16 -16 -16 -16 16 16 16 16 16 16 16
16 16 16 16 16 16 16 16 16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16
-6 -16 -16 -16 -16 -16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -6 -16 -16 -16 -16 -16
16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 -16 -16 -16 -16 -16
-16 -16 -16 -16 -16 -6 -16 -16 -16 -16 -16 16 16 16 16 16 16 16 16
16 16 16 16 16 16 16 16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -6
-16 -16 -16 -16 -16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
-16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -6 -16 -16 -16 -16 -16 16
16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 -16 -16 -16 -16 -16
-16 -16 -16 -16 -16 -6 -16 -16 -16 -16 -16 16 16 16 16 16 16 16 16
16 16 16 16 16 16 16 16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -16 -6
-16 -16 -16 -16 -16]
and so on for N = 1024, 4096, etc
please paste the code.
In: Computer Science
Implement the MSI cache coherence protocol in your favorite programming language (C, C++, Java, python, etc.). Wikipedia has a nice high level description of the protocol. Consider only one level of cache which is a write back cache. Moreover, assume that there are 4 processing cores working on a single shared memory. To simplify, assume that you are writing the code for only one block of cache and that block can hold 4 different memory locations.
In: Computer Science
linux Regular expressions
file name: lab3test.txt
Create regular expressions that meet the following criteria. You may use grep or egrep to answer these questions.
1.Display all lines where the employee’s age is greater than 40 years old. Again, don’t think of this as a number, think of it as a series of characters.
In: Computer Science