In C: Find a string within a string Given two strings S1 & S2, search for an occurrence of the second string within a first string. Note: Do not use system library for the implementation. Input: Code Zinger University Zinger where, First line represents string S1. Second line represents string S2. Output: 5 Here 'Zinger' word starts at 5th index within 'Code Zinger University’. Assume that, The length of strings S1 & S2 are within the range [1 to 10000]. Character comparisons will be case-sensitive.
In: Computer Science
Develop a test strategy for testing the entire application chosen in unit 3 for analysis and design. Keep in mind that testing that involves users should minimize their time commitment while obtaining essential information from their involvement. Specifically define roles, responsibilities, timing, and test strategy for each level of testing.
In: Computer Science
In: Computer Science
Write a linear-search Java method to test if a String array is already sorted alphabetically. The prototype should be static boolean ifsorted(String [] s)
{
}
In: Computer Science
Java programming extra credit.
The following program will be used to test your knowledge on Implementing with tester classes. Included is the Details class. Your assignment is to create a class named DetailsTester using info from the two classes(Procedure class is only included to know the details of the procedure, which includes desc, date, and cost) Patient class is included as well.That will properly implement the class.
package doctorOffice; | |
import java.time.LocalDate; | |
import java.time.LocalDateTime; | |
import java.util.ArrayList; | |
public class Patient extends Person | |
{ | |
//Instance variables | |
private LocalDate birthDate; | |
private Details details; | |
//Default Constructor | |
public Patient() { } | |
//Constructor | |
public Patient(String name, | |
LocalDate birthDate, | |
int ssn) | |
{ | |
this.name = name; | |
this.birthDate = birthDate; | |
this.ssn = ssn; | |
} | |
//Getters-------------------------------------- | |
public Details getDetails() | |
{ | |
return details; | |
} | |
public LocalDate getBirthDate() | |
{ | |
return birthDate; | |
} | |
} |
package doctorOffice;
import java.util.ArrayList;
import java.time.LocalDate;
public class Details
{
//Instance variables
private Patient patient;
private double height;
private double weight;
private ArrayList procedures = new ArrayList();
private LocalDate lastVisit;
Details(Patient patient,
double height,
double weight)
{
this.patient = patient;
this.height = height;
this.weight = weight;
}
//Getters--------------------------------------
public Patient getPatient()
{
return patient;
}
public double getHeight()
{
return height;
}
public double getWeight()
{
return weight;
}
public ArrayList getProcedures()
{
return procedures;
}
public LocalDate getLastVisit()
{
return lastVisit;
}
//Setters--------------------------------------
public void setHeight(double height)
{
this.height = height;
}
public void setWeight(double weight)
{
this.weight = weight;
}
public void setLastVisit(LocalDate lastVisit)
{
this.lastVisit = lastVisit;
}
//Methods--------------------------------------
public boolean addProcedure(Procedure toAdd)
{
//LOGIC HERE
return true;
}
}
*******
package doctorOffice;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
//Procedure class holds information about any procedures
performed on the patients
public class Procedure
{
private String desc;
private double cost;
private LocalDate date;
public Procedure(String desc, double cost, String
date) throws Exception
{
this.desc = desc;
this.cost = cost;
this.date = LocalDate.parse(date,
DateTimeFormatter.ofPattern("MM/dd/yyyy"));
}
//getters
public String getDesc()
{
return this.desc;
}
public double getCost()
{
return this.cost;
}
public LocalDate getDate()
{
return this.date;
}
//toString override
public String toString()
{
String output = "Description: " +
desc;
output += "\n\nCost: " +
cost;
output += "\n\nDate: " +
date.toString();
return output;
}
}
In: Computer Science
In: Computer Science
I'm looking for a program, written in vPython, that simulates the movement of a spherical mass, suspended from a ceiling, tied to a spring. We are supposed to take the gravitaional force into account but are allowed to ignore the effects of air-resistance (for now).
I am a newbie at vPython so comments within the program to explain what certain parts of the code do would be appreciated!
In: Computer Science
An increasing-order integer array may contain duplicate elements. Write a Java method that does a binary search through the array for finding a specific target and return an array of two integer indices that specifies the close interval of indices at which the target is found or null if the target is not present. Use this test driver to test
public class MultBS
{
int [] multBinarySearch(int [] x, int target)
{
// your codes go here
}
public static void main(String [] args)
{ int [] x = new int[]{2,3,3,4,4,4,5,6,7,7,7};
int [] range = multBinarySearch(x, 3);
System.out.println("Target was found from position " + range[0] + " to " + range[1]);
}
}
test your program to make sure you see
the printout is
"Target was found from position 1 to 2"
In: Computer Science
I have the following code:
//Set.java
import java.util.ArrayList; public class Set<T> { //data fields private ArrayList<T> myList; // constructors Set(){ myList = new ArrayList<T>(); } // other methods public void add(T item){ if(!membership(item)) myList.add(item); } public void remove(T item){ if(membership(item)) myList.remove(item); } public Boolean membership(T item){ for (T t : myList) if (t.equals(item)) return true; return false; } public String toString(){ StringBuilder str = new StringBuilder("[ "); for(int i = 0; i < myList.size() - 1; i++) str.append(myList.get(i).toString()).append(", "); if(myList.size() > 0) str.append(myList.get(myList.size() - 1).toString()); str.append(" ]"); return str.toString(); } }
(20 points) Fill the following table with the big-O running times of each of the methods implemented, as well as the running times for the same methods if they were implemented with LinkedList instead. (No need to explain here, only the big-O expression.)
Array List | Linked List | |
add | ||
remove | ||
membership | ||
toString |
(20 points) Explain each of the eight running times in the table applying the rules of counting seen in class, and for the method calls, if 4 we have covered them already, directly refer to the running times of those methods. (Partial credit if you do not explain all eight. No points for ambiguous explanations. For instance, if you implement add in the class Set using addFirst in the class ArrayList, then you should say something like the following. “The add method of Set is implemented with just one method call to addFirst of ArrayList. addFirst of ArrayList is in O(n) in the worst case. Hence, the same bound on the running time applies to add”. )
In: Computer Science
Suppose a function receives a pointer as an argument. Explain how this function is declared within its calling function. In particular, explain how the data type of the pointer argument is represented. C++
In: Computer Science
What are the application and uses of Telemedicine?
In: Computer Science
please give complete code in python using def function thank you!
Validate Credit Card Numbers
Credit card numbers can be quickly validated by the Luhn checksum algorithm.
For instance, Ned Flander's credit card number is 8525.4941.2525.4158.
Here are the digits with checksum underlined:
8525494125254158_
Here are the digits doubled back:
16 5 4 5 8 9 8 1 4 5 4 5 8 1 10 8_
Here are the two-digit results subtracted nine:
7 5 4 5 8 9 8 1 4 5 4 5 8 1 1 8_
Here is the sum:
7+5+4+5+8+9+8+1+4+5+4+5+8+1+1+8=83
Here is the modulo 10 result: 83%10=3 and this is not a valid credit card number.
Compose a function luhn which correctly validates a given candidate 16-digit credit-card number (as a numeric input in int).
In: Computer Science
hi! I have this code. when I run it, it works but in
the print(the number we are searching for is ) it prints the number
twice. ex. for 5 it prints 55 etc. apart from this, it
works
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int n,i;
printf("Give me the size of the table : \n");
scanf("%d", &n);
int A[n],x,y;
for (i=0;i<n;i++)
A[i]=rand() % n;
for (i=0;i<n;i++)
printf("%d\n", A[i]);
srand(time(NULL));
y=rand()% n ;
printf("The number we are searching for is %d", y);
for (i=0;i<n;i++)
{
if (A[i]==y)
{
printf("%d is present at location
%d.\n", y,i+1);
break;
}
}
if (i == n)
printf("%d isn't present in the array.\n",
y);
return 0;
}
In: Computer Science
hours = 40;
status= True;
overtime = False
What is the value of each of the following Boolean expressions? [4 marks]
In: Computer Science
Rewrite the following Matlab code so it does the same thing but
with complete new variable names and structure.
function stump = stumpGenerator(dataX, dataY, Dt)
intervals = 100;
rangex1 = max(dataX(:,1)) - min(dataX(:,1));
rangex2 = max(dataX(:,2)) - min(dataX(:,2));
width = (rangex1/intervals);
height = (rangex2/intervals);
starterx1 = min(dataX(:,1)) - (width/2);
starterx2 = min(dataX(:,2)) - (height/2);
currepsilon = inf;
stump = [0,0,0,1,0,0];
for i = 1:(intervals + 1)
horzRightError = sum(Dt(find(((dataX(:,1) - starterx1) .* dataY)
< 0)));
horzLeftError = sum(Dt(find(((dataX(:,1) - starterx1) .* dataY)
> 0)));
vertUpError = sum(Dt(find(((dataX(:,2) - starterx2) .* dataY) <
0)));
vertDownError = sum(Dt(find(((dataX(:,2) - starterx2) .* dataY)
> 0)));
if (horzRightError <= horzLeftError)
horzError = horzRightError;
else
horzError = -horzLeftError;
end
if (vertUpError <= vertDownError)
vertError = vertUpError;
else
vertError = -vertDownError;
end
if (abs(horzError) <= abs(vertError))
if (currepsilon > abs(horzError))
currepsilon = abs(horzError);
stump(1) = 1;
stump(2) = 0;
stump(3) = starterx1;
stump(4) = horzError/(abs(horzError));
stump(5) = (log((1 - currepsilon)/currepsilon))/2;
stump(6) = currepsilon;
else
% do nothing, we already have the best stump
end
else
if (currepsilon > abs(vertError))
currepsilon = abs(vertError);
stump(1) = 0;
stump(2) = 1;
stump(3) = starterx2;
stump(4) = vertError/(abs(vertError));
stump(5) = (log((1/currepsilon) - 1))/2;
stump(6) = currepsilon;
else
% do nothing, we already have the best stump
end
end
starterx1 = starterx1 + width;
starterx2 = starterx2 + height;
end
end
In: Computer Science