Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
This is a java coding String manipulation Question.
Let us say I have a String which looks something likes this:
String x = "MATH,PHYSICS,CHEMISTRY,CODING"
And then I have another String which looks something like this:
String y = "XXXXMXXXAXXXTXXXXHXXXXXXCXXXXOXXXXDXXXIXXXXNXXXGXXXX"
and another String that looks like this:
String z = "XXXXHXXTXXXXAXXMXXXXXCXXXOXXXDXXXIXXXNXXXG"
I want to take String y and print the words that are found in String x as such:
Math
Coding
and for String z if I want to take it and print the words also found in x as such:
Math
Coding
So basically I want to the program to print the possible words from the letters I have in String y and z.
and only print possible words from my String x.
I want to know how I can do such thing please explain so that I understand what is going on. I have tried replacing the Xs with nothing and then I would have the letters and then I'll use it to check if it has something in String x. but that made me use arrays and also if I replaced Xs with nothing and I had to words in Z or Y then I'll end up with something I can not work with only letters.
I have also thought about making a char array from the resulting String after replacing Xs. and then split String x by ',' and after make a char array of each word and then check if the char array of each word contains the chars of the resulting String after replacing Xs with nothing.
but that also does not work.
I think this is a simple problem that I am over complicating.
Please help and thank you.
In: Computer Science
Explain any android application in detail and on your own words
it should include the purpose, security features and you suggest to improve it
In: Computer Science
Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float-
point type and the two constants are defined as follows:
#define NUM_ROW 4
#define NUM_COLUMN 4
float Value[NUM_ROW][NUM_COLUMN] =
{
2.1, 2.2, 2.3, 2.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.1, 2.2, 2.3, 2.4
};
Write a C++ main function that computes and prints out the following information about
this 2d array:
(1) The mean of all the Value[][] array elements (0.5 points).
(2) The median of all the Value[][] array elements (0.5 points)
(3) The local average values of all the array elements (1.0 points). For instance, the
local average value at position i, j = (Value[i-1][j]+Value[i+1][j]+Value[i][j+1]+Value[i][j-1]+Value[i][j])/5.
If (i+1) > NUM_ROW-1 or (i-1) < 0, use modulus operator to wrap around to the other end of the array index.
Create another array: Average[NUM_ROW][NUM_COLUMN], and use this array to store the values
of local average at each position of this 2d array. At the end, you need print out
the values of all the array elements of Average[][] on computer screen.
Parts (2) only please.
In: Computer Science
Create a website for an online movie
rental store, using HTML (and any other
client technologies) and PHP. The website should
include:
- A front/home page containing a list of movies available for rent (list at least 10 movies).
o Each movie should have a listed rental price.
o Additional information provided:
§ name of actors in the movie (list at least 2)
- The home page should link to a form for renting a movie
o Selecting and submitting a movie for rent will lead to a page displaying
§ the name of the movie rented,
§ the amount charged (calculated with 5% tax),
§ the date and time rented, and § the date and time the movie is due for return (in 5 days).
- A form linked through the home page for selecting a movie and submitting a user review.
o Input fields should include
§ The name of the movie
§ Username
§ Rating in 5 stars
§ User review
o Output after submitting a review should show the name of the movie and all submitted information.
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
This problem should be solved using the DrRacket software in Racket/Scheme language.
Write a function (merge-sorter L1) that takes list-of-integers L1 and returns all elements of L1 in sorted order. You must use a merge-sort technique that, in the recursive case, a) splits L1 into two approximately-equal-length lists, b) sorts those lists, and then c) merges the lists to obtain the result. See the following examples for clarificaton.
(merge-sorter '(3 1 5 4 2) ---> (1 2 3 4 5) (merge-sorter '()) ---> () (merge-sorter '(1)) ---> (1)
In: Computer Science
Q: Let’s say you have an unordered list of numbers and you wanted to put them in order from lowest to highest value. How would you do that? You’re probably thinking that you would just look at all the numbers, find the lowest number and put it at the beginning of your list. Then you would find the next largest number and put it in the second spot in the list, and so on until you’ve ordered the entire list of numbers. It’s simple, basic, and not very exciting. Now, let’s say that instead of ordering the list yourself, you decide it’s a better idea to write a computer program to order the list for you. Now you don’t have to deal with moving the numbers around, you just need to tell your program how to move the numbers, and then let the program handle any list you give it.Identify all possible ways of telling your program how to move the numbers, where each way provides the required result.
(Note: The program code is preferred to be in Java)
In: Computer Science
Download labSerialization.zip and unzip it:
ListVsSetDemo.java:
package labSerialization;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Demonstrates the different behavior of lists and sets.
* Author(s): Starter Code
*/
public class ListVsSetDemo {
private final List<ColoredSquare> list;
private final Set<ColoredSquare> set;
/**
* Initializes the fields list and set with the elements
provided.
*
* @param elements
*/
public ListVsSetDemo(ColoredSquare... elements) {
list = new ArrayList<>(Arrays.asList(elements));
set = new HashSet<>(Arrays.asList(elements));
}
/**
* Creates a string that includes all the list elements.
* Each element is followed by a new-line.
*
* @return string of list elements
*/
public String getListElements() {
StringBuilder sb = new StringBuilder();
for (ColoredSquare el : list) {
sb.append(el).append("\n");
}
return sb.toString();
}
/**
* Creates a string that includes all the elements in the set.
* Each element is followed by a new-line.
*
* @return string of set elements
*/
public String getSetElements() {
StringBuilder sb = new StringBuilder();
for (ColoredSquare el : set) {
sb.append(el).append("\n");
}
return sb.toString();
}
/**
* Adds the element <code>el</code> to both the list and
the set.
*
* @param el
*/
public void addElement(ColoredSquare el) {
list.add(el);
set.add(el);
}
}
ColoredSquare.java:
package labSerialization;
import java.awt.Color;
/**
* A square that is defined by its size and color.
* Author(s): Starter Code
*/
public class ColoredSquare {
private final int side;
private final Color color;
/**
* Initializes the fields <code>side</code> and
<code>color</code>.
* @param s the side length of the square
* @param c the color of the square
*/
public ColoredSquare(int s, Color c) {
side = s;
color = c;
}
/**
* Calculates the area of the square.
*/
public int area() {
return side * side;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((color == null) ? 0 :
color.hashCode());
result = prime * result + side;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof ColoredSquare))
return false;
ColoredSquare other = (ColoredSquare) obj;
if (color == null) {
if (other.color != null)
return false;
} else if (!color.equals(other.color))
return false;
if (side != other.side)
return false;
return true;
}
@Override
public String toString() {
return String.format("side:%d #%02X%02X%02X",
side, color.getRed(), color.getGreen(),
color.getBlue());
}
}
LabSerialization.java:
package labSerialization;
import java.awt.Color;
/**
* LabSerialization demonstrates how to serialize and
deserialize
* a custom object that references other objects on the heap.
* Author(s): Starter Code + ........... // fill in your name
*/
public class LabSerialization {
public static void main(String[] args) {
ListVsSetDemo demo = new ListVsSetDemo(
new ColoredSquare(4, Color.RED),
new ColoredSquare(6, Color.BLUE),
new ColoredSquare(4, Color.RED),
new ColoredSquare(8, Color.YELLOW));
displayListAndSet(demo);
};
/**
* Displays the elements of the list and the set.
*/
private static void displayListAndSet(ListVsSetDemo demo) {
System.out.println("List:");
System.out.println(demo.getListElements());
System.out.println("Set:");
System.out.println(demo.getSetElements());
}
}
In class ListVsSetDemo
In class ColoredSquare:
In class LabSerialization:
Sample Output
This sample output should give you a good idea of what is
expected. Note though, that the elements in HashSet are in no
particular order. Because of that, the second part of the output
might look slightly different.
Sample Output
List:
side:4 #FF0000
side:6 #0000FF
side:4 #FF0000
side:8 #FFFF00
Set:
side:6 #0000FF
side:8 #FFFF00
side:4 #FF0000
In: Computer Science
This problem should be solved using the DrRacket software in the Racket/Scheme language.
Consider two techniques for representing a graph as Scheme lists. We can represent a directed graph as a list of edges. We call this representation an el-graph (i.e. edge-list graph). An edge is itself a list of length two such that the first element is a symbol denoting the source of the edge and the second element is a symbol denoting the target of the edge. Note that an edge is a list (not just a pair). For example, the following is a graph: '((x y) (y z) (x z)). We can also represent a graph similar to an adjacency matrix. We call this representation an x-graph (i.e. matrix-graph). In this case, a graph is a list of adjacencies where an adjacency is a list of length two such that the first element is a node (a symbol) and the second element is a list of the targets of that node. For example, the following is a graph: '((x (y z)) (y (z)) (z ())).
- Write function (el-graph->x-graph g), that accepts an el-graph g and returns an x-graph of g.
- Write function (x-graph->el-graph g), that accepts an x-graph g and returns an el-graph of g.
In: Computer Science
Question 1
[multiple answer] a relation in mathematics
Question 2
[multiple answers] in the relational model, relations are commonly used
Question 3
[multiple answers] constraints on relations in normal RDBMSs (not considering MS access)
Question 4
[multiple answers] which of the following constraints can be violated by inserting a record into a database table?
Question 5
[multiple answers] which of the following constraints can be violated through a deletion of a record from a database table?
Question 6
[multiple answers] assume a table A with primary key aid, and a table B with primary key bid and foreign key aid which references aid in table A. Which of the following operations can result in a violation of the referential integrity (foreign key) constraint?
Question 7
[multiple answers] referentially triggered actions
Question 8
[multiple answers] a 1-to-1 relationship in the entity-relationship model can be represented in the relational model
Question 9
[multiple answers] a 1-to-many relationship in the entity-relationship model can be represented in the relational model
Question 10
[multiple answers] a many-to-many relationship in the entity-relationship model can be represented in the relational model
In: Computer Science
This was my prompt, and I'm not quire sure what to do.
1. Circle:
Implement a Java class with the name Circle. It should be in the package edu.gcccd.csis.
The class has two private instance variables: radius (of the type double) and color (of the type String).
The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated.
Construction:
A constructor that constructs a circle with the given color and sets the radius to a default value of 1.0.
A constructor that constructs a circle with the given, radius and color.
Once constructed, the value of the radius must be immutable (cannot be allowed to be modified)
Behaviors:
Accessor and Mutator aka Getter and Setter for the color attribute
Accessor for the radius.
getArea() and getCircumference() methods, hat return the area and circumference of this Circle in double.
Hint: use Math.PI (https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI (Links to an external site.))
2. Rectangle:
Implement a Java class with the name Rectangle. It should be in the package edu.gcccd.csis.
The class has two private instance variables: width and height (of the type double)
The class also has a private static variable: numOfRectangles (of the type long) which at all times will keep track of the number of Rectangle objects that were instantiated.
Construction:
A constructor that constructs a Rectangle with the given width and height.
A default constructor.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
getArea() and getCircumference() methods, that return the area and circumference of this Rectangle in double.
a boolean method isSquare(), that returns true is this Rectangle is a square.
Hint: read the first 10 pages of Chapter 5 in your text.
3. Container
Implement a Java class with the name Container. It should be in the package edu.gcccd.csis.
The class has two private instance variables: rectangle of type Rectangle and circle of type Circle.
Construction:
No explicit constructors.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
an integer method size(), that returns 0, if all member variables are null, 1 either of the two member variables contains a value other than null, and 2, if both, the rectangle and circle contain values other than null.
In: Computer Science
I want to make the Main function of this program to only drive. So, make more functions, and change main function to just drive.
This program Dice Game.
Based on this C++ program below:
#include <iostream>
#include <cstdlib>
using namespace std;
int cheater(int computer, int user){
cout<<"Using cheat"<<endl;
if(computer>user)return computer+rand()%2;
if(computer==3 || computer==18)return computer;
if(user>computer)return computer -1;
}
int main()
{
int user, computer,sum,u_diff,c_diff,u_win=0,c_win=0;
int gameCount=0;
bool enableCheat=false;
int lastGameWon=0;
do
{
cout<<"User guess is(1 - 18) :";
cin>>user;
if(user>=3&&user<=18) //the sum of three dice should
be between 3 to 18
{
gameCount+=1;
cout<<"Computer guess is :";
computer=rand()%16+3;
cout<<computer<<endl<<"User guess is :
"<<user<<endl;
cout<<"Sum of the three rolls is :";
sum=rand()%16+3; //rand()%16 will generate the random number
between 0 to 15.
if(enableCheat)sum=cheater(computer,user);
cout<<sum<<endl;
u_diff=user-sum;
c_diff=computer-sum;
if(u_diff<0){
u_diff=u_diff* -1; //u_diff,c_diff is the diffence and it should
always be positive.
}
if(c_diff<0){
c_diff*=c_diff* -1; //if u_diff or c_diff is negetive than we make
it positive.
}
if(u_diff<c_diff){
cout<<"user won\n";
u_win++;
if(lastGameWon+1==gameCount)enableCheat=true;
lastGameWon=gameCount;
} else{
cout<<"computer won\n";
c_win++;
enableCheat=false;
}
cout<<"User won: "<<u_win<<" times.";
}else if(user >= 19 || user <= 0){
cout<<"please enter between 1 to 18\n";
}
}while(user!=-1);
return 0;
}
In: Computer Science
Public static boolean isPalindrome(String word)
* Check to see if a word is a palindrome. Should be
case-independent.
* @param word a String without whitespace
* @return true if the word is a palindrome
Public static int longestWordLength(String words)
* Returns length of the longest word in the given String using
recursion (no loops).
* Hint: a Scanner may be helpful for finding word boundaries. After
delimiting by space,
* use the following method on your String to remove punctuation
{@code .replaceAll("[^a-zA-Z]", "")}
* If you use a Scanner, you will need a helper method to do the
recursion on the Scanner object.
* @param words A String containing one or more words.
* @return The length of the longest word in the String.
* @see Scanner#Scanner(String)
* @see Scanner#next()
* @see String#split(String)
* @see String#replaceAll(String, String)
* @see Math#max(int, int)
In: Computer Science