Python language:
Write a function dice(n) that returns a list
with the results of n dice rolls conducted with a six sided dice.
Use Numpy's random number functions to do this (Hint: use
randint() within numpy's random
module).
i.e. dice(3) returns something like [2,3,5] to indicate the first
dice obtained a 2, the second a 3 etc
In: Computer Science
Use your webcam and record a movie, write a motion detection code and print the message "Motion Detected" on the original frame. Try to make a better visualization by using different masking. Using OpenCv, pandas,numpy
code be written in python,
In: Computer Science
* The course name Ethics in information Technology*
1-Using your research skills, find the meaning of the following terms, which constitute important parts of trustworthy software:
-Security
--Reliability
-Privacy
2-List your references. (You should have at least 3 references)
In: Computer Science
write a code in python for evolutionary search method for multivarible
In: Computer Science
Write a Java program that reads a name and displays on the screen.
In: Computer Science
Let Σ be a finite alphabet with n letters and let R be the relation on Σ* defined as follows: R = {(u, v): every letter in u occurs somewhere in v, and every letter in v occurs somewhere in u} Then R is an equivalence relation with exactly 2n equivalence classes.
T or F?
In: Computer Science
C++ Project 1
For this project, we are going to create our own classes and use them to build objects. For each class you will create an *.h and *.cpp file that contains the class definition and the member functions. There will also be one file called 'main.cpp' that obviously contains the main() function, and will instantiate the objects and test them.
You will create 2 new classes for this project, one will be from the list below and one will be a required 'Date' class. Here is the list:
WebSite
Shoes
Beer
Book
Song
Movie
TVShow
Computer
Bike
VideoGame
Car
The process is: take your assigned class from the list such as Book. Add to your project new files called Book.h and Book.cpp and create the new class from scratch in those files. I suggest following the simple technique for adding a class discussed in the lecture. Do not overthink. Just come up with the 3 most important data members that describe the class/object you want to build and the write 2 constructors, 3 get member functions, 3 set member functions and a toString method and you are done.
Once you have created a new class, you need to adjust the main() function to allow the user to input the data members for your class and create an object of that type. Use the toString method to then display the new object on the screen. When the project is complete, both classes/objects should be created and displayed with main().
Please do not use the same 3 data types for any class's member variables. That is, do not make them all ' int ' or all ' string '.
As for the Date class, the data members will be int day; int
year; string month; Create a Date class with 2 constructors, 3 get
member functions, 3 set member functions and a toString method.
Adjust the main() function to use the Date class.
When the user wants to build a Date object, on the screen I would
input 3 values, one for each member variable. Insert values into
the Date object then output a simple message like:
"The Date object is: March 2, 2013"
It is very important that the data input be inserted INTO the object, and pulled back OUT of the object to print the above message.
To ensure you complete each class, use this checklist:
_____ Three global variables (not the same type) _____ Two constructor methods _____ Three 'get' methods _____ Three 'set' methods _____ One 'toString' method _____ In the main function you create an object, insert values into the object, and print the object
Good Luck
Upgrade the Date Class
There are three (3) levels of understanding of objects. The first is objects are composed of variables and methods. Variables should be private and simple set/get methods allow us to insert data into and pull data back out of the objects.
The second level of understanding is objects should verify their data! To prevent 'Garbage IN, Garbage OUT' the object should NEVER allow bad data to be assigned to the member (or global) variables. Modify the set methods and constructors of the date class to make SURE the day value is always between 1 and 31, make sure the year value is between 1970 and 2099. If the user tries to assign a bad value, print a simple error message and DO NOT change the value of the variable. Example, the 'setDay' is called with the value 99, a simple message like "Value of day is not in range 1 to 31" should be output and the variable day SHOULD NOT be modified.
The third level of understanding is objects are SMART! Methods can and do generate actions and information that are not explicitly stored in the object. The date class has a string month variable that stores "jan", "feb" ... "dec". Everyone knows month could ALSO be stored as an integer value 1 ("jan") to 12 ("dec"). But we DO NOT need to store BOTH; we can generate the number when needed. Write a method: int getMonthNumber(); that returns the proper value 1-12 based on the string stored in the month variable. It should return the value -1 if the current value in the month variable is NOT valid. DO NOT store the month number in a member variable (local is OK), generate it when the method is called.
Write a method: void printDate( int format ); when it is called the format value will determine how the date is output to the screen using cout:
format 0: Mar 12, 2013
format 1: 12 Mar 2013
format 2: 3-12-2013
format 3: 3/12/13
Of course the actual values stored in the object will be output, this is only an example. Modify the main program to print the date in these additional formats. Optional: Use the int getMonthNumber(); method to check if the user enters a proper value for the month variable.
In: Computer Science
C# programming
This application will calculate the speed of an interstellar spacecraft as it accelerates though our galaxy to explore the stars. The spacecraft is using a new engine technology that continues to accelerate over time with no limit, allowing the spacecraft to reach distant areas of the galaxy at record speed. The spacecraft starts out slowly, but for each day it accelerates, it will double the speed it has attained prior to that point. The spacecraft will accelerate from 0 MPD (Miles Per Day) at launch to 1000 MPD by the end of the first day, and will have covered 500 miles (average speed of (0 + 1000)/2= 500). At the end of day two, it will be up to 2000 MPD (double day one's speed), and will have covered 2000 miles total (the previous day’s 500 miles plus the new day’s average of (1000+2000)/2)). Create an app that allows the user to enter the number of days the spacecraft has been traveling and your app will use the formulae given, plus some looping code, to tell the user what the speed of the spacecraft is (in MPD) at the end of that day. Your app will also calculate the total distance traveled by the spacecraft to the end of that day (also done with the fomulae and some looping code). Create a form with the appropriate controls to get the user input and display the answers correctly. Ensure you do proper data validation so that any mistakes the user makes entering data do not crash the program or create/allow strange results
In: Computer Science
QUERY PROCESSING JOIN
1) Let the schema of a relation r as R(A,B,C), and a relation s has schema S(C,D,E). Relation table r has 40K tuples, relation s has 60K tuples. The block factor of r is 25. The block factor of s is 30. Let the average seek time is t S and average block transfer time is t T . Assume you have a memory that contains M pages, but M< 40K/25 (indicating that s cannot be entirely loaded to the main memory). Assume there is no index. Estimate the worst-case costs of the following query r s using each of the following join strategies:
• Nested Loop Join
• Block Nested Loop Join
• Merge join
• Hash join
In: Computer Science
Write a Java program that reads a whole number on the keyboard and obtains and displays twice and triple that number on the screen
In: Computer Science
Describe the popular uses of the macOS (at least 2 paragraphs).
In: Computer Science
Write program#1 upload .java file.
#1 Write a java program that prompts the user for input using the Scanner class.
<END>
In: Computer Science
Programming Language = JAVA
I wanna make menu -driven using these items.
1. one
2. two
3. three
4. four
5. exit
This program will read a txt data and will display them in console.
text.txt
98765432,C,John,Smith,23 Church Ave,Central,2123,8,Valid
98765431,C,Joe,Smith,55 Church Street,Genzi,2323,0,Valid
98765430,C,Bob,Smith,23 Gong Road,Warambull,2443,0,Valid
98765429,C,Mike,Smith,42 Mike Street,Waterloo,2222,0,Valid
98765428,C,Juan,Smith,522 Banana steet,Bank,2423,2,Valid
98765427,C,Mike,Jones,232 Milemium
lane,Sumrise,2753,13,Suspended
98765426,C,David,Smith,551 Russian Mountain
ave,Kogara,2121,0,Valid
98765425,C,Sarah,Smith,123 Straight
Street,Cronulla,2232,3,Valid
98765424,C,James,Smith,23 lane,Coroloa,2345,7,Valid
98765423,C,Mike,White,4 Loman Lane,Orange,2665,14,Suspended
98765422,C,Brendon,Fei,55 bal bay,sate,2757,0,Valid
98765421,C,Jian,Zhang,62 london Street,mango,2553,0,Valid
98765420,C,Choi,Saraha,11 hamberguer
Street,kefece,2753,0,Valid
98765432,C,Godam,City,32 Kent Street,Maccus,2876,0,Valid
when user press 1, this program will display a report about this txt file.
a report will include number(98765420), family name, first name, suburb, point(0,3,2,,,), status(valid).
please display well-organized format, and also please provide special option which displays this report in the decending order of point(0,3,2).
In: Computer Science
Please Work on the commented parts in the code
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
void printArray(int *arr, int size){
int i;
for( i = 0; i < size; i++) {
// Print each element out
printf("%d ", *(arr+i));
//Print addresses of each element
printf("%p", (arr+i));
//Printing a new line
printf("\n");
}
}
int main() {
// Allows user to specify the original array size, stored in
variable n1.
printf("Enter original array size: ");
int n1 = 0;
scanf("%d", &n1);
//a- Create a new array *a1 of n1 ints using malloc
int *a1 = malloc(n1 * sizeof(int));
//b- Remove comments for if statment below
//b- Set each element in a1 to 100 + indexValue ??
// if(a1 == NULL)
// {
// printf("Error! memory not allocated.");
// exit(0);
// }
printf("Printing the first array allocated using
malloc\n");
//c- Print each element and addresses out (to make sure things look
right)
// User specifies the new array size, stored in variable n2.
printf("\nEnter new array size: ");
int n2 = 0;
scanf("%d", &n2);
//d- Dynamically change the array a1 to size n2
//e- Remove comments for if statment below
//e- If the new array is a larger size, set all new members to 200
+ indexValue.
// if(a1 == NULL)
// {
// printf("Error! memory not allocated.");
// exit(0);
// }
printf("Printing the reallocated array: \n");
//f- Print each element and addresses out (to make sure things look
right)
//g-Free the allocated memory for a1
printf("\nEnter new array size to be initialized with 0: ");
int n3 = 0;
scanf("%d", &n3);
//h- Remove comments for if statement
//h- Using calloc create a new array and assign it to a2
//with new array size, stored in variable n3.
// if(a2 == NULL)
// {
// printf("Error! memory not allocated.");
// exit(0);
// }
printf("Printing the array created using calloc: \n");
//i- Print array a2 with size n3
//j- Print array a1 again, How you can fix this problem
printf("Printing deallocated array a1: \n");
// Done with arrays now, free the allocated memory and assign
NULL
//free(a2);
//a1 = NULL;
//a2 = NULL;
printf("Program Successfully Completed!");
return 0;
}
In: Computer Science
Write program#2 upload .java file.
2A) Write a java program that uses the Random class to generate a number in the range 21 to 64. Print the generated number.
2B) Using the Random class and nextInt(6), rolls two die generating two random numbers each in the range 1 through 6. Total by adding the two values together. Print the value of each die, and the total value.
2C) Using the Math class and sqrt(num), calculate the square root of integer twenty-two divided by integer seven, print the result formated to ten decimal places. Hint: the result of the division needs data conversion to support a double.
<END>
In: Computer Science