%Purpose:
%Fit a first degree polynomial,
%a second-degree polynomial,
%and a third-degree polynomial to these data
%Plot all three plots (along with the original data points)
%together on the same plot and determine the BEST fit
%After determining the best fit add additional code to the end of
your script
%to predict the pressure at t = 11 seconds from the best-fitting
curve
%INPUT VARIABLES:
t = 1:0.05:10;
p = [26.1,27,28.2,29,29.8,30.6,31.1,31.3,31,30.5];
d1 = polyfit( t, p, 1 ); %first degree
d2 = polyfit( t, p, 2 ); %second degree
d3 = polyfit( t, p, 3 ); %third degree
t1 = 1:0.05:10;
p1 = polyval(d1,t1);
p2 = polyval(d2,t1);
p3 = polyval(d3,t1);
%
%OUTPUT VARIABLES:
%plot(t,p,'o') original data points
%plot(t, p1,)first degree
%plot(t, p2,)second degree
%plot(t, p3, '--')third degree
%title ('Fuel Line Pressure Predictions');
%xlabel('Time (sec)');
%ylabel('Pressure (psi)');
%
%OUTPUT SECTION:
plot(t,p,'o')
plot(t1,p1);
plot(t1,p2);
plot(t1,p3,'--');
title ('Fuel Line Pressure Predictions')
xlabel('Time (sec)')
ylabel('Pressure (psi)')
I am not sure what is wrong with my code. The errors that pop up are:
Error using polyfit (line 44)
The first two inputs must have the same number of elements.
Error in EngrProb_1 (line 17)
d1 = polyfit( t, p, 1 ); %first degree
In: Computer Science
A transport layer protocol uses the id of the process rather than the port number to specify the destination. (Explain the reason)
1. Is there any problem for senders who wish to connect to a well-defined service (for example, Apachewebserver)?
2. Will there be any problems with the process of multiple network connections?
3. If the host has a different operating system, will there be any problem?
In: Computer Science
4.
An identifier name in a program may represent
Group of answer choices
a location
a specific machine memory address
a value
all of the above
none of the above
In order for a language to support unbounded length character strings, it must have:
Group of answer choices
static storage allocation
dynamic storage allocation
static type checking
dynamic type checking
Suppose that the vehicle registration department for the State of Florida is becoming decentralized. Each county will now handle its own registration process and will issue its own license plates. However, there needs to be some centralized checking so that counties do not duplicate plate design, etc. Counties also need to notify each other if an address listed for a registration is not within their county.
The county systems must also interface with State systems for tax and other purposes. So, while the system will be mostly decentralized, there will still exist a need for centralized data access.
A consulting firm was hired to develop this system and they have narrowed the choice of programming language to Java and C#.
What do you think about their choice of programming
languages?
How would you evaluate their choice of these programming
languages?
In: Computer Science
In: Computer Science
Using this 1000-digit string:
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Write the following method: public static int
largestValue(String str)
1. Take a single String parameter
2. Work from the beginning to the end of the string,
3. identify the five-character group that represents the largest
five-digit number.
4. The method is then to return the largest five digit value in the
String as an integer.
Note:
1. Only one 5-digit group is to be identified and returned, so if
two or more identical values are in the string, only one of those
values is to be returned.
2. Each 5-digit group is built upon every single digit in the group
(less the final four digits), so the first two five-digit groups
will be the following: 73167, 31671, and so on. The last five-digit
group will be 63450.
3. Must use the String class substring( ) method to solve the above
problem.
4. The five-digit groups are to be evaluated as integers, and the
value of the largest five-digit number is to be returned as an
integer.
PLEASE HELP ME UNDERSTAND HOW TO COMPLETE THIS METHOD OR WHERE TO LEARN MORE I AM LOST HERE THANK YOU, BELOW IS WHAT A START:
public class Problem2StarterFile
{
public static void main(String [] args)
{
//variable declarations
String s = "73167176531330624919225119674426574742355349194934"
+
"96983520312774506326239578318016984801869478851843" +
"85861560789112949495459501737958331952853208805511" +
"12540698747158523863050715693290963295227443043557" +
"66896648950445244523161731856403098711121722383113" +
"62229893423380308135336276614282806444486645238749" +
"30358907296290491560440772390713810515859307960866" +
"70172427121883998797908792274921901699720888093776" +
"65727333001053367881220235421809751254540594752243" +
"52584907711670556013604839586446706324415722155397" +
"53697817977846174064955149290862569321978468622482" +
"83972241375657056057490261407972968652414535100474" +
"82166370484403199890008895243450658541227588666881" +
"16427171479924442928230863465674813919123162824586" +
"17866458359124566529476545682848912883142607690042" +
"24219022671055626321111109370544217506941658960408" +
"07198403850962455444362981230987879927244284909188" +
"84580156166097919133875499200524063689912560717606" +
"05886116467109405077541002256983155200055935729725" +
"71636269561882670428252483600823257530420752963450";
System.out.println("The largest value is: " + largestValue(s));
}
public static int largestValue(String str)
{
//PLEASE HELP ME UNDERSTAND HOW TO COMPLETE THIS METHOD OR WHERE TO
LEARN MORE I AM LOST HERE THANK YOU
return(0);
}
}
In: Computer Science
In: Computer Science
Generic Stack due 10/16/2020 Friday 12 pm Mountain Time
Generic Stack
Make It Generic!
The first part of this lab is making your stack generic. Take the code from your working StringStack class - everything except the main method - and paste it into the GenericStack class. Change the name of the constructors to match the new name of the class, then modify the whole class so it uses generics, and can store any type that a programmer asks for.
Numbers and Readers
To take advantage of polymorphism, Java has a lot of inheritance hierarchies built-in. You may not have known that simple numeric classes, like Integer and Float, are actually part of one! Java contains a generic number class creatively called Number, and pretty much any class in Java whose purpose is to store numbers inherits from this class.
There are many types of Readers that can extract characters from different things, such as Strings, Files, and arrays.
Scrolls of Numbers
A few years back, I bought a box of random numbers from an intrepid salesman who insisted they were special. I'd like to find out if that's really the the case. Unfortunately, I've stored the numbers in a bunch of different places - some of them are in Strings, others are in files, it's a bit of a mess.
So I created a generic calculator that, using Readers, can read in a list of numbers from any source, put them into a stack, and then add them all up. Since I'm a good programmer, I put each of these steps in their own functions... but it looks like I accidentally erased some of them. Your next task in the lab is to repair my generic stack calculator by fixing the functions.
Wrapping up
you should get output that looks somewhat like this (exact numbers may vary due to floating-point rounding):
76.4 76.39999961853027 4584425.0 15.324
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.*;
public class GenericStack {
/* YOUR CODE HERE
* Just like in the ArrayList lab, copy your StringStack code,
excluding the
* main method, here.
* Then, modify it so it's generic!
*/
public static void main(String[] args) {
// If any of these lines cause a compilation error, your stack
hasn't
// been properly made generic.
GenericStack intStack = new GenericStack<>();
GenericStack stringStack = new GenericStack<>();
GenericStack> listStack = new GenericStack<>();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.*;
import java.io.*;
import java.math.*;
public class Calculator {
public static void main(String[] args) throws FileNotFoundException, IOException {
String numbers = "56 3 7 2.0 8.4";
char[] moreNumbers = "1.0 2 3 4 5 0.324".toCharArray();
GenericStack stack1 = makeStack(new
StringReader(numbers));
System.out.println(evaluate(stack1));
GenericStack stack2 = new GenericStack<>();
for (String token : numbers.split(" ")) {
stack2.push(Float.parseFloat(token));
}
System.out.println(evaluate(stack2));
GenericStack stack3 = makeStack(new
FileReader("numbers.txt"));
System.out.println(evaluate(stack3));
GenericStack stack4 = makeStack(new
CharArrayReader(moreNumbers));
System.out.println(evaluate(stack4));
}
/* This function is meant to take in a Reader called "reader" and
return a
* stack of Numbers.
*
* Remember: don't change anything that's already there. Just add
your new
* code where the comment is to fix the function's signature.
*/
public static /* ??? */ throws IOException {
GenericStack stack = new GenericStack<>(64);
char[] data = new char[64];
reader.read(data);
String tokens = new String(data);
for (String token : tokens.split(" ")) {
stack.push(parse(token));
}
return stack;
}
/* This function is meant to take in a stack of ANY KIND of
Number
* called "stack", and return the double you get if you add all of
the
* numbers together.
* The function must be able to accept a stack of ANY KIND of
Number!
*
* Hint: use wildcard generics!
*/
public static /* ??? */ {
/* implement me! */
return 0.0;
}
/* This function is missing a return type.
* Examine it, and see if you can tell what type it should
return.
* (Spoiler: it's probably what you think it is.)
*/
public static /* ??? */ parse(String s) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) { }
try {
return Double.parseDouble(s);
} catch (NumberFormatException e) { }
return new BigDecimal(s);
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.*;
public class StringStack {
private String [] stack;
public int size, top;
public StringStack(int size) {
this.top=-1;
this.size=size;
stack= new String[size];
}
public StringStack() {
this.size=10;
this.top=-1;
stack= new String[this.size];
}
public boolean empty() {
return this.top==-1;
}
public String peek() {
if (this.top==-1) {
throw new
NoSuchElementException("Empty stack!");
}
else {
return this.stack[this.top];
}
}
public String pop() {
if (this.top==-1) {
throw new NoSuchElementException("Empty
stack!");
}
else {
return this.stack[this.top--];
}
}
public String push(String s) {
if (this.top>=this.size-1) {
throw new IllegalStateException("Stack is
full!");
}
this.stack[++this.top]= s;
return this.stack.toString();
}
public int search(String s) {
int dist = 0;
int top = this.top;
while(top>=0) {
if(this.stack[top]==s) {
return
dist;
}
dist++;
top--;
}
return -1;
} /* I removed the public static void main method from StringStack
Class because I was getting a prompt saying the question is too
long on Chegg there should not be an issue we just have to convert
the methods above to generic as mentioned by copy and pasting it in
GenericStack class and then modifying it. This all the
formation*/
In: Computer Science
AVL Group assignment
POST ANSWER IN JAVA PLS
Populate a tree via a text file (input.txt) Make sure that after every insert, the tree is balanced. At the end, display the tree in level format. Make sure to include the height and the balance factor of every node in your output. Redirect the display to an output file (output.txt)
Hint:
//I will not accept any other algorithm
//This is not a recursive algorithm
node * rebalance(node *node){
node->height = max(height(node->left), height(node->right)) + 1;
int balance = getBalance(node); //node->left - node->right
/*do rotations as necessary
If Left heavy outside : return rightRotate(node);
If right heavy outside: return leftRotate(node);
If left heavy inside: left rotation first, right rotation 2nd, return top node
node->left = leftRotate(node->left);
return rightRotate(node);
if right heavy inside: right rotation first, left rotation 2nd, return top node
node->right = rightRotate(node->right);
return leftRotate(node);
if no rotation, return node
*/
}
//non-tail recursive algorithm because of rebalance
node* insert(node* node, int key)
{
//recursive Code for inserting a node
//When insert happens set height to 0 for the node
if (node == NULL)
return(newNode(key));
if (key < node->key)
node->left = insert(node->left, key);
else
node->right = insert(node->right, key);
node=rebalance(node); //update heights and rebalance
return node;
}
node *leftRotate(node *x){
struct node *y=x->right;
//add more code to rotate to the left, update heights for x and y
//return y
}
node *rightRotate(node *x){
struct node *y=x->left;
//add more code to rotate to the right, update heights for x and y
//return y
}
POST ANSWER IN JAVA PLS
In: Computer Science
discuss the main characteristics of the database approach and how it differs from traditional file systems.
In: Computer Science
what is the extended definition of MongoDB, Cassandra, influxdb, and neo4j?
In: Computer Science
In: Computer Science
Class as a ChapteredVideo. The constructor should take the following parameters:
ID, length, num_chapters, chap_lengths, location, [extension]
The new parameter should be stored as their own instance variables. The ChapteredVideo object should behave as the Video. However, the method get_ID should now return a list which contains whatever the Video previously would return as its ID as the first element, followed by a list of chapter names. Each chapter name will be formed by the ID of the main video followed by ‘#’ and then the chapter number (starting at 1). For instance, a valid list could be ["123", "123#1", "123#2", "123#3"]. The ChapteredVideo class should also have a new accessor method, get_num_chapters.
Implement ChapteredVideo class as specified above.
In: Computer Science
Topic: Database testing techniques
Write a research paper on this topic but task is that i write just
scope of this paper
Brief Idea (not more than 200 words): Define scope of your
project
List of papers which u take (Minimum of 8 paper at least 4 papers
after 2016)
Kindly provide some research paper which are related with my
topic
In: Computer Science
PLEASE READ CAREFULLY!!!!
write a client.py and server.py file for tic-tac-toe IN PYTHON with the following restrictions (SO WRITE TWO FILES THAT PLAY PYTHON THROUGH A SOCKET)
Use a 5 x 5 grid (dimensions are subject to change, so use
constants for NUM_ROWS and NUM_COLS)
Use 'X' for player 1 and 'O' for player 2 (symbols and the number
of players is subject to change, so use constants)
Each player can make 1 move per turn before having to wait for the
next player to move. If an illegal move is made, an
error message is sent to the player by the server and the player
loses the current turn
SO AGAIN TO RECAP A TIC TAC TOE PROGRAM IN PYTHON THAT ALLOWS TWO PLAYERS TO PLAY TOGETHER, a client and a server file
In: Computer Science
2) Complete the parameterized constructor that takes arguments that are used to initialize ALL class’s member variables. [2 points] 3) Complete the code for getTitle() member function. The function returns the title of the Song. [1 point] 4) Complete the code for getDurationSec() member function, which returns the duration in seconds instead of minutes. [2 points] 5) Write member function definitions for three member functions below: [3 points] void setTitle(string t); //set title to t void setAuthor(Author a); //set author to a void setDurationMin(double d); //set durationMin to d 6) Demonstrate how you can use the Song class in the main() function. Prompt users to enter the details of songs, store each song in a list (vector) then print out the Song objects from the list. The grading rubric for this question is shown below
In: Computer Science