The command below produces a row vector of 100 random values uniformly distributed between -10 and +10.
r = 10.*rand(1,100)-10;
r = 20.*rand(1,100)-10;
r = -10.*rand(1,100)+10;
r = 10.*rand(1,100)-20;
In: Computer Science
Suppose you are given a list of n integers, each of size at most 100n. How many operations would it take you to do the following tasks (in answering these questions, we are interested primarily in whether it will take logn, sqrt(n), n, n^2, n^3, 2^n, ... steps. In other words, ignore multiplicative constants.)
1. Determine the longest sequence of consecutive integers belonging to the list.
2. Determine the number of primes in the list.
3. Determine whether there are three integers x, y and z from the list so that x + y = z.
4. Determine whether there are three integers x, y, and z from the list so that x^2 + y^2 = z^2.
In: Computer Science
Plot a dot matric using the sliding window 1 nucleotides long and setting up a stringency threshold of 1 out 1 matches for putting a dot in the relevant element on the dot matrix. Draw a line on the dot matrix and write down the corresponding alignment between these two sequences.
AACTAGCCCCATGCAAGCATT
ACTAGCGCGCCTCATGCAGCATT
In: Computer Science
In: Computer Science
Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program:
Min miles: -10 Max miles: 40
#include <iostream>
using namespace std;
int main() {
const int NUM_ROWS = 2;
const int NUM_COLS = 2;
int milesTracker[NUM_ROWS][NUM_COLS];
int i;
int j;
int maxMiles = -99; // Assign with first element in milesTracker
before loop
int minMiles = -99; // Assign with first element in milesTracker
before loop
int value;
for (i = 0; i < NUM_ROWS; i++){
for (j = 0; j < NUM_COLS; j++){
cin >> value;
milesTracker[i][j] = value;
}
}
/* Your solution goes here */
cout << "Min miles: " << minMiles <<
endl;
cout << "Max miles: " << maxMiles << endl;
return 0;
}
In: Computer Science
Write a C++ program that asks for the name and age of three people. The program should then print out the name and age of each person on a separate line from youngest to oldest.
Hint: Start with a program that just asks for the names and ages then prints them out in the same order they are entered. Then modify the program so it prints out the list of names in every possible order. Note that one of these will be the correct result. Then add conditions to each set of results so that only one set of results is true.
For example; part of my program will print:
name2
name1
name3
Therefore the condition for this output would be: (age2
< age1) && (age2 < age3) && (age1 <
age3)
You can assume that all three ages will be different but consider what your program would do if two or more ages were the same. (If your program is written correctly - it should not matter)
Use if, else if and else statements in order to minimize the total number of comparisons. (See Rubric for how you will be graded on use of conditionals)
HINT: Plan out you approach ahead of time. Use pseudocode or flow chart if that helps.
Example Output:
Peter 2 Paul 20 Mary 54
In: Computer Science
4. Consider the following two alternative ER designs:
• a ternary relationship set R that relates entity sets A, B, and C.
• a design in which R is replaced by an entity set E with E related to A, B, and C by 3 binary relationship sets RA, RB and RC , respectively.
Explain why, as stated, these two may not be equivalent. Then explain what could be done to make them equivalent by fixing each of RA, RB and RC , to be 1-1. m-m, 1-m, or m-1.
In: Computer Science
IN PYTHON
Complete the following tasks, either in a file or directly in the Python shell.
Using the string class .count() method, display the number of occurrences of the character 's' in the string "mississippi".
Replace all occurrences of the substring 'iss' with 'ox' in the string "mississippi".
Find the index of the first occurrence of 'p' in the string "mississippi".
Determine what the following Python function does and describe it to one of your Lab TAs :
def foo(istring):
p = '0123456789'
os = ''
for iterator in istring:
if iterator not in p:
os += iterator
return os
In: Computer Science
I need this Java code translated into C Code. Thank you.
//Logical is the main public class
public class Logical {
public static void main(String args[]) {
char [][] table=
{{'F','F','F'},{'F','F','T'},{'F','T','F'},{'F','T','T'},{'T','F','F'},{'T','F','T'},{'T','T','F'},{'T','T','T'}};
// table contains total combinations of p,q,& r
int totalTrue, totalFalse, proposition;
//proposition 1:
proposition=1;
start(proposition);
totalTrue=0;
totalFalse=0;
for(int i=0;i<8;i++)
{
{
char o=
conjuctive(implecation(negation(table[i][0]),table[i][1]),implecation(table[i][2],table[i][0]));
System.out.println(" "+table[i][0]+" "+table[i][1]+"
"+table[i][2]+" "+o);
if(o=='T')
totalTrue++;
else
totalFalse++;
}
}
finalOutput(totalTrue,totalFalse,proposition);
System.out.println(" ");
System.out.println(" ");
//proposition 2:
proposition=2;
start(proposition);
totalTrue=0;
totalFalse=0;
for(int i=0;i<8;i++)
{
{
char o=
conjuctive(disjunctive(table[i][0],negation(table[i][1])),disjunctive(table[i][2],negation(implecation(table[i][0],table[i][1]))));
System.out.println(" "+table[i][0]+" "+table[i][1]+"
"+table[i][2]+" "+o);
if(o=='T')
totalTrue++;
else
totalFalse++;
}
}
finalOutput(totalTrue,totalFalse,proposition);
System.out.println(" ");
System.out.println(" ");
//Proposition 3
proposition=3;
start(proposition);
totalTrue=0;
totalFalse=0;
for(int i=0;i<8;i++)
{
{
char o=
implecation(table[i][0],implecation(negation(conjuctive(table[i][0],negation(table[i][1]))),conjuctive(table[i][0],table[i][1])));
System.out.println(" "+table[i][0]+" "+table[i][1]+"
"+table[i][2]+" "+o);
if(o=='T')
totalTrue++;
else
totalFalse++;
}
}
finalOutput(totalTrue,totalFalse,proposition);
System.out.println(" ");
System.out.println(" ");
//Proposition 4
proposition=4;
start(proposition);
totalTrue=0;
totalFalse=0;
for(int i=0;i<8;i++)
{
{
char o=
conjuctive(conjuctive(table[i][0],implecation(table[i][0],table[i][1])),negation(table[i][1]));
System.out.println(" "+table[i][0]+" "+table[i][1]+"
"+table[i][2]+" "+o);
if(o=='T')
totalTrue++;
else
totalFalse++;
}
}
finalOutput(totalTrue,totalFalse,proposition);
/* //Proposition 0
proposition=0;
start(0);
totalTrue=0;
totalFalse=0;
for(int i=0;i<8;i++)
{
{
char o=
conjuctive(table[i][0],conjuctive(table[i][1],negation(table[i][2])));
System.out.println(" "+table[i][0]+" "+table[i][1]+"
"+table[i][2]+" "+o);
if(o=='T')
totalTrue++;
else
totalFalse++;
}
}
finalOutput(totalTrue,totalFalse,proposition);*/
}
//method to check contradiction & tautology
static public void finalOutput(int totalTrue,int totalFalse,int
proposition)
{
System.out.println(" "+totalTrue+" combination result in
Proposition " +proposition+" being T");
System.out.println(" "+totalFalse+" combination result in
Proposition "+proposition+ " being F");
if(totalTrue==8)
System.out.println(" Proposition "+ proposition+ " is a
tautology");
else if(totalFalse==8)
System.out.println(" Proposition " + proposition+" is a
contradiction");
else
System.out.println(" Proposition "+proposition +" is neither a
tautology nor a contradiction");
}
static public void start(int i)
{
System.out.println(" "+"p"+" "+"q"+" "+"r"+" "+"Proposition "+
i);
System.out.println("----------------------------------------------------");
}
// negation method
static public char negation(char x)
{
if(x=='T')
return 'F';
else
return 'T';
}
// disjuctive method
static public char disjunctive(char x, char y)
{
if(x=='T' || y=='T')
return 'T';
else
return 'F';
}
// conjuctive method
static public char conjuctive(char x, char y)
{
if(x=='F' || y=='F')
return 'F';
else
return 'T';
}
// implecation method
static public char implecation(char x,char y)
{
if((x=='T' && y=='T') ||(x=='F' && y=='F') ||
(x=='F' && y=='T'))
return 'T';
else
return 'F';
}
}
In: Computer Science
Create a two-part form that calculates weekly income for Happy Diner's waitress Tammy, based on her regular hours, overtime pay, and tips. She makes $10 an hour, if she works 40 hours a week, or less. Her overtime pay is $15 an hour. If Tammy worked over 40 hours, she is earning her overtime wages. Happy customers give her tips as well.
Use an HTML document named tipsYourlastname.html as a Web form with two text boxes — one for the number of hours worked and one for the tips. Use a PHP document named tipsyourlastname.php as the form handler. Output the total amount earned to the screen in some nice organized manner. Please comment your code appropriately and test your program with various input to ensure it operates correctly. Check your math as well.
Please remember that program has to work to get credit. This is a very small program, but you need to plan ahead and give yourself enough time for testing and debugging. Write a small piece of code at a time and test it before you add more code. Work incrementally.
In: Computer Science
" line 48"
return delta.days
^
SyntaxError: 'return' outside function
import datetime
def nowDate():
current_time = datetime.datetime.now()
new_time = datetime.datetime(
current_time.year,
current_time.month,
current_time.day,
0,
0,
0,
)
return new_time
def plusOneDay(daytime):
tomorrow = daytime +
datetime.timedelta(days=1)
return tomorrow
def nDaystoHoliday():
NJCU_holidays = [
(datetime.date(2019, 1,
1), "New Year's Day"),
(datetime.date(2019, 1,
21), 'Martin Luther King, Jr. Day'),
(datetime.date(2019, 2,
19), "President's Day"),
(datetime.date(2019, 4,
19), 'Good Friday'),
(datetime.date(2019, 5,
27), 'Memorial Day'),
(datetime.date(2019, 7,
4), 'Independence Day'),
(datetime.date(2019, 9,
2), 'Labor Day'),
(datetime.date(2019, 10,
14), 'Columbus Day'),
(datetime.date(2019, 11,
11), "Veteran's Day"),
(datetime.date(2019, 11,
28), 'Thanksgiving'),
(datetime.date(2019, 12,
25), 'Christmas Day'),
]
now = datetime.datetime.now().date()
print (now)
date = NJCU_holidays[0][0]
print (date)
for i in range(1, len(NJCU_holidays)):
holiday = NJCU_holidays[i][0]
delta = holiday - now
if(delta.days > 0):
return delta.days
time = nowDate()
plusOneDay(time)
nDaystoHoliday()
In: Computer Science
Continue performing the steps in this appendix, starting with
the section called Developing the
Schedule. Print out the following screens or send them to your
instructor, as directed:
a. Figure A-32. All task durations and recurring task entered
b. Figure A-39. Network diagram view
c. Figure A-46. Changing Work hours for tasks
d. Figure A-56. Earned value report
e. Continue performing the steps, or at least read them. Write a
one-to-two page paper
describing the capabilities of Project Professional 2016 and your
opinion of this software.
What do you like and dislike about it?
In: Computer Science
Write a program that will input the information for 2 different employees. Prompt the user for the first employee’s name, hours worked and rate. Compute the salary and display it. Do the same for the second and third employees. Then, display a message to the effect that the highest salary is whatever and the lowest salary is whatever. When the program runs, the following should display information should line up just as I have it below. E:\> java Quiz4 Name:
John Doe Class: CSCI 1250-001 (or 002) Date: September 18, 2019 Program: Quiz4.java First Employee:
John Smith Hours Worked: 40.0 Rate of pay: 10.0 Salary for John Smith is $400.00
Second Employee:
Sarah Jones Hours worked: 30.0 Rate of pay: 7.50 Salary for Sarah Jones is $225.00
Third Employee: Andrew Johnson Hours Worked: 31.5 Rate of pay: 10.75 Salary for Andrew Johnson is $338.63
The largest salary is $400.00 The smallest salary is $225.00
In: Computer Science
Given this class:
class Issue
{
public:
string problem;
int howBad;
void setProblem(string problem);
};
And this code in main:
vector<Issue> tickets;
Issue issu;
a)
tickets.push_back(-99);
State whether this code is valid, if not, state the reason
b)
Properly implement the setProblem() method as it would be outside of the class. You MUST name the parameter problem as shown in the prototype like:
(string problem)
c)
Write code that will output the problem attribute for every element in the tickets vector. The code MUST work for no matter how many elements are contained in tickets. The output should appear as:
Problem #1 is the problem attribute in element 1.
Problem #2 is the problem attribute in element 2.
In: Computer Science
Write a java code to demonstrate the File IO. Your code should get the following information from the user.
• Get a file name fname for output • Get number of data (numbers) (N) you want to process from the user
• Get N numbers from the users through keyboard and store them in an array
• Get M (How many numbers to read from file)
• (Or)You are free to use same N for M (use N for both purposes) You have to define two methods:
1) To write the numbers from the array into the file fname
2) To read numbers from the file fname, store them in an array, and compute average of the numbers.
The method should display the numbers from the array and the average value.
In: Computer Science