Questions
Write a program to print random numbers and whether they were even or odd. Ask the...

Write a program to print random numbers and whether they were even or odd. Ask the user to enter a positive number to indicate how many random numbers to pull (verify number is positive). Zero is positive.

Declare two variables and initialized to zero.
int evens = 0, odds = 0;
Use them to count how many evens and how many odds were pulled.
Enter how many random numbers to pull : 3
41           odd
18467    odd
6334    even
1 even and 2 odd random numbers were generated.

In: Computer Science

The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName,...

The following tables form part of a database held in a relational DBMS:

Hotel (hotelNo, hotelName, hotelAddress, country)

Room (roomNo, hotelNo, type, price)

Guest (guestNo, guestName, guestAddress, country)

Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)

Write the SQL statements for the following questions:

1. List the rooms that are currently unoccupied at the Grosvenor Hotel, for:

(a) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use NOT IN to perform the difference operation

(b) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use NOT EXISTS to perform the difference operation.

(c) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use LEFT JOIN to perform the difference operation.

(d) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use MINUS to perform the difference operation.

In: Computer Science

(PYTHON) Lottery program. The program randomly generates a two-digit number, prompts the user to enter a...

(PYTHON) Lottery program. The program randomly generates a two-digit number, prompts the user to enter a single two- digit number, and determines whether the user wins according to the following rules. Write a loop to let the user play as many times as the user wanted. Use a sentinel or flag to quit out of the loop.

1.if the user’s input matches the lottery In the exact order, the award is $10,000.

2.if all the digits in the user’s input match all the digits in the lottery number, the award is $3,000.

3. if one digit in the user’s input matches a digit in the lottery number, the award is $1,000.

In: Computer Science

Write 3 classes with three levels of hierarchy: Base, Derive (child of base), and D1 (child...

Write 3 classes with three levels of hierarchy: Base, Derive (child of base), and D1 (child of Derive class). Within each class, create a “no-arg” method with the same signature (for example void m1( ) ). Each of this method (void m1( ) ) displays the origin of the Class type. Write the TestDynamicBinding Class: (the one with the ‘psvm’ ( public static void main (String[] args)) to display the following. You are NOT allowed to use the “standard object.m1() “to display the message in the main(…) method. That would NOT be polymorphic! (minus 10 points for not using polymorphic method) Explain why your solution demonstrates the dynamic binding behavior? (minus 5 points for lack of explanation) From Parent Class From Derived:Parent Class From Derived:Parent Class From D1:Derived Class Explain why this demonstrates dynamic polymorphism: (minus 4 points for lack of explanation)

In: Computer Science

JAVA) I need to get 10 integer numbers from the user. Then I need to find...

JAVA) I need to get 10 integer numbers from the user. Then I need to find sum of odd numbers, sum of even numbers, the lowest number of all numbers, the highest number of all numbers, and the average of all numbers( use double, with the two digit decimal)

process;

loopCount = 1

While LoopCount <= 10

Read number from the keyboard

If odd, add to the total of all odd numbers

If even, add to the total of all even numbers

Add to the total of ALL numbers

Determine the smallest and largest number

Increment loopCount

End Loop Identify and display all three totals and range of numbers

Compute and display the average

In: Computer Science

Using Java, Given an array A[0 ... n-1], where each element of the array represent a...

Using Java,

Given an array A[0 ... n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.

In: Computer Science

c++ students.txt 20 Shawn Lynch 2.0 Hasan Stephens 2.6 Frank Wright 2.7 Hugo Ray 2.9 Justin...

c++

students.txt

20

Shawn Lynch 2.0
Hasan Stephens 2.6
Frank Wright 2.7
Hugo Ray 2.9
Justin Gardner 3.0
Kelly Jenkins 2.2
Rafael Seymour 3.7
Jose Cantu 0.6
David Gilmore 1.3
Emma Paterson 2.1
Jackie White 1.9
Robert Green 3.8
Julio Armstrong 1.1
Erik Cook 4.0
Jessica Hale 3.0
Vanessa Rivera 0.9
Sandra Ferguson 3.1
Christian Wang 1.1
Jackson Martinez 1.9
Austin Black 4.0

For your program, you will need to define a class Student, with private members for first name, last name, and GPA, and any methods you determine that you need (constructors, gets/sets, etc.) Once the class is defined, you will need to populate an array of Student objects to be sorted with data provided in the students.txt file.

First line in the text file will be size of the array.

Every line after the first contains three pieces of information, separated by spaces: First Name, Last Name, and GPA

and sort the Student data by GPA.(Using MergeSort)

display unsorted data and sorted data

In: Computer Science

Let G be any context-free grammar. Show that the number of strings that have a derivation...

Let G be any context-free grammar. Show that the number of strings that have a derivation in G of length n or less, for any n > 0, is finite.

Could you please answer with clear explanation. The question is from Elaine Rich's Automata, Computability and Complexity Chapter 11 Exercise 14.

In: Computer Science

<HTML JAVASCRIPT> Please create an array of student names and another array of student grades. Create...

<HTML JAVASCRIPT>

Please create an array of student names and another array of student grades.

Create a function that can put a name and a grade to the arrays.

Keep Read student name and grade until student name is “???”. And save the reading by using a function

Create another function to show all the grade in that object.

Create the third function that can display the maximum grade and the student’s name.

Create a sorting function that can sort the arrays based on the student’s grade.

Display all the grades and names sorted by the grade.

[Report]

PLEASE POST OUTPUT IN NOTEPAD++ or NOTEPAD! Thanks

In: Computer Science

Averaging measurements: Use python 3 to write this program Assume that someone has collected a set...

Averaging measurements: Use python 3 to write this program

Assume that someone has collected a set of measurements and wants some statistical data about them. Write a program that asks a user for measurements and prints the average, the maximum, and the minimum measurement. Users should be allowed to enter as many measurements as they want, until entering a negative measurement. The negative measurement should not be processed, but is just used to indicate that the user has finished entering measurements. [Note: do not use a list to store the measurements.]

Note: Complete without using import sys. Only use simple for and while loops and if else statements.

In: Computer Science

Summary Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of...

Summary

Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day and average miles run each day.

Instructions

Write a program to help them analyze their data. Your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. Furthermore, your program must contain at least the following functions:

  • a function to read and store the runners’ names and the numbers of miles run each day;
  • a function to calculate the average number of miles run each day;
  • and a function to output the results. (You may assume that the input data is stored in a file and each line of data is in the following form: runnerName milesDay1 milesDay2 milesDay3 milesDay4 milesDay5 milesDay6 milesDay7.)

In: Computer Science

Do a bit of research on penetration testing techniques. Investigate and document the following Five network...

Do a bit of research on penetration testing techniques. Investigate and document the following Five network penetration testing techniques Advantages and disadvantages of each One notable social engineering test Possible negative implications of penetration testing Please write between 200 and 300 words

In: Computer Science

Mention the model fit indices for determining the predictive accuracy of classification methods.

Mention the model fit indices for determining the predictive accuracy of classification methods.

In: Computer Science

Can you give a java code example of using a singleton pattern and factory pattern design...

Can you give a java code example of using a singleton pattern and factory pattern design together?

In: Computer Science

Using Java, design a program that creates an array of Card objects, shuffles them, then recursively...

Using Java, design a program that creates an array of Card objects, shuffles them, then recursively sorts them by value and then recursively sorts them by value and suit



You will need to create a Card class with the following two fields:
• value (a String)
• suit (a String)
You may include any other fields, constructors, or methods as needed.
Your single array will need to contain 52 card objects, one for each value of each suit. The values to use are 2-10, J, Q, K, and A, with A being the card with the highest value. The suit values to use are H (for Hearts), D (for Diamonds), C (for Clubs), and S (for Spades).
After building the array, shuffle the array using the Fisher-Yates Algorithm. You must implement this algorithm yourself. After shuffling, print each object’s value and suit to show the array was shuffled. The output for each object printed should be VALUE - SUIT. For example: 2 - H.
Then, you’ll need to recursively sort the array based on the values. All 2 cards should be at the beginning and all A cards should be at the end; The suit is irrelevant here. After sorting, print each object’s value and suit again to show the array was sorted based on the cards’ values.Finally, you’ll recursively sort the array based on the values and suit. Clubs should be first, then Diamonds, then Hearts, then Spades. Each suit should be sorted from 2-A. After sorting, print each object’s value and suit again to show the array was sorted based on the cards’ values and suits.


please comment

In: Computer Science