Language Javascript
Implement Insertion Sort
1. Non-increasing order,
2. At least an array of 10 elements.,
3. You can use a static array.
In: Computer Science
Describe the A* algorithm. Give one search example: give one graph as example with a heuristic function for each node; give the start node and goal node; apply the A* algorithm on this problem. Show the steps and sequence of nodes visited in order that leads to the optimal solution.
In: Computer Science
Write a program that translates an English word into a Pig Latin word. Input ONE, and ONLY one, word from the user, and then output its translation to Pig Latin.
The rules for converting a word to Pig Latin follow.
Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters.
Input Specification
Input ONE English word as a string. If multiple words are entered ignore any beyond the first.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
Please enter a word ==>
Output Specification
Output an introductory message, a prompt for the English word, and a translation for the inputted word.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING. The output below assumes the user entered "Hunger".
This program will convert an English word into Pig Latin. Please enter a word ==> Hunger "Hunger" in Pig Latin is "unger-Hay"
Required Methods
// Prompt and read a word to translate public static String readWord (Scanner console) // Convert a word to Pig Latin and return it public static String convertWord (String englishWord) // Return true if "c" is a vowel, false otherwise. // Handle both lowercase and uppercase letters. public static boolean isVowel (char c) // Print result of translation public static void printResult (String englishWord, String pigLatinWord)
Hints
BEFORE you start coding, think about which methods each method will call. Which methods should "main" call? Create a diagram which shows the calling relationships.
There are many useful String methods listed HERE. You may find startsWith and charAt helpful.
Style
Write comments
In: Computer Science
Write a C++ script to perform the following:
a.) Ask a user to enter 2 real numbers.
b.) Save the user response as a variable a and b.
c.) Display if the numbers are even or odd.
d.) Check if the number a belongs in the interval D = [10, 99],
display the output as "a is between 10 and 99" or "a is not between
10 and 99".
e.) Check if the number b belongs in the interval E = [0, 50],
display the output as "b is between 0 and 50" or "b is not between
0 and 50".
In: Computer Science
Digital Forensics, At least 200 words for each question
1/ Research a network attack (DDoS, Man-in-the-Middle, IP Spoofing, etc.) and explain it in further detail.
2/ Discuss ways that forensic examiners have been able to identify and analyze these attacks.
3/ Find an attack , where an examiner was able to successfully identify the attacker, and explain techniques used to do so.
In: Computer Science
I want to calculate the max, min, mean, standard deviation and the percentage of data within one standard deviation from a file already existing in my directory using JAVA. As you can see it below, I have found max, min, mean and stand deviation. How can I get the percentages of data within one standard deviation in the following code?
import java.io.*;
import java.util.Scanner;
public class DataFile {
public static void main(String[] args) {
// declare variables
double number, maximum, minimum, sum, mean, standardDeviation;
int count;
Scanner file = null;
/* -------------------------------------------------------------------------- */
try {
file = new Scanner(new File("RawData.txt"));
}
catch(FileNotFoundException e) {
System.out.print("Error; The program was terminated!");
System.exit(1);
}
/* -------------------------------------------------------------------------- */
// initialize variables
maximum = file.nextDouble();
minimum = maximum;
sum = 0;
count = 1;
while(file.hasNextDouble()) {
number = file.nextDouble();
if(number > maximum)
maximum = number;
else if(number < minimum)
minimum = number;
sum += number;
count += 1;
} // end while loop
file.close();
/* -------------------------------------------------------------------------- */
// mean calculation
mean = sum / count;
// standard deviation calculation
double stdDevSum = 0;
double stdDevMean = 0;
double stdDev = 0;
double sumOfSquares = squareSum - ((Math.pow(computationalSum, 2)/(count-1)));
double sSquared = sumOfSquares/(count-1);
double otherStdDev = Math.sqrt(sSquared);
// display statistics
System.out.println("Maximum ------------> " + maximum );
System.out.println("Minimum ------------> " + minimum );
System.out.println("Sum ----------------> " + sum );
System.out.println("Count --------------> " + count );
System.out.println("Mean ---------------> " + mean );
System.out.println("StdDev -------------> " + otherStdDev);
} // end method main
} // end class DataFileIn: Computer Science
I would like to see a PowerShell script(for purely inspirational work to use as an inspiration for helping to develop my skills as a hobby.
*** This should all be done in a loop **
Before beginning, You will need a simple text file with three weeks of scores between Michigan and Michigan State. Example:
UM21, MSU 14
UM28, MSU 35,
UM14, MSU 3
1) Then I need a loop that reads in the attached text file
2) Read the scores by school and determine if MSU or Michigan won or lost
3) - if the wolverines win, have user put the score into the win file (win.txt)
** UM win over MSU55-10 **
- if the wolverines encounter a loss, put the score in the loss file (loss.txt)
** wolverines lose to spartans 24-17 **
NOTE: the permission must be changed on the file in order to write to it
*** the file permission switching must be done in separate script ***
4) please zip contents of wolverines and sparty directories
In: Computer Science
C++
Question1. Create a class called Rantional for performing arithmatic with fractions. Then write a program to test your class. Use integer variables to represent the private data of the class, meaning the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in
case no initializers are provided and should store the fraction
in reduced form. For example fraction 2/4 would be stored in the
object as 1 for the numerator and 2 for the denominator.
Note: Remember that denominator cannot be 0.
Provide public member functions that perform each of the following
tasks:
a) add -- Adds 2 rational numbers. Result should be stored in
reduced form.
b) subtract -- Subtracts 2 rational numbers. Store result in
reduced form.
c) multiply -- Multiplies 2 rational numbers. Store result in
reduced form.
Write a main() function to test above functionalites.
In: Computer Science
Assume a 2.8 MByte file is being uploaded from a client application to a web server. Answer the following questions from the perspective of the protocol stack on the client.
a. What protocol is in use at the application layer?
b. Is this application layer protocol reliable?
c. The application layer hands this 2.8 MByte file to the transport layer. What protocol is in use at the transport layer?
d. Is this transport layer protocol reliable?
e. Is this transport layer protocol connection oriented or connection-less?
f.What does the transport layer do with this 2.8 MByte file?
g. The transport layer then hands its data off to what layer?
h. What is the responsibility of this next layer?
In: Computer Science
Question #14. a. TRUE OR FALSE: Code written using a case/switch construct can always be rewritten using an if/else construct. Explain why or why not. b. TRUE OR FALSE: Code written using an if/else construct can always be rewritten using a case/switch construct. Explain why or why not.
matlab
In: Computer Science
(MATLAB) im trying to solve an equation for gravitational force for 41 radius values in between 3.8e8 to 4e8, heres a snippet of the code... how would a create this equation to solve for all 43 values (3.8e8 - additional 41 values in between- 4e8) the values are evenly spaced. (MATLAB)
r=(3.8e8:(2e7/42):4e8);
Mass_earth=5.97e24;
Mass_moon=7.34e22;
Force=((G*Mass_earth*Mass_moon)/(r^2));
fprintf(''),disp(Force(1))
In: Computer Science
In: Computer Science
What output is produced by the following code fragment?
int num = 0, max = 20;
while (num < max)
{
System.out.println(num);
num += 4;
}
In: Computer Science
Posting 3 times , still not get right answer
(The MyInteger class) Design a class named MyInteger. The class
contains:
* An int data field named value that stores the int value
represented by this object.
* A constructor that creates a MyInteger object for the specified
int value. A getter method that returns the int value.
* The methods isEven(), isOdd(), and isPrime() that return true if
the value in this object is even, odd, or prime,
respectively.
* The static methods isEven(int), isOdd(int), and isPrime(int) that
return true if the specified value is even, odd, or prime,
respectively.
* The static methods isEven(MyInteger), isOdd(MyInteger), and
isPrime(MyInteger) that return true if the specified value is even,
odd,or prime, respectively.
* The methods equals(int) and equals(MyInteger) that return true if
the value in this object is equal to the specified value.
* A static method parseInt(char[]) that converts an array of
numeric characters to an int value.
* A static method parseInt(String) that converts a string into an
int value.
Write a client program that tests all methods in the class. Given that the definition of a prime number is a positive integer be sure to instruct the use to only enter positive integers.
SAMPLE RUN #1
--- Prompts For Keyboard/Console/Standard Input ---
Enter a positive integer to create a MyInteger object or to move
on to next part of program:
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:
Enter a the first of two positive integers to create obj2 and test
obj2.equals(int) or to move on to next part of program:
Enter a the second of two positive integers to test
obj2.equals(int):
Enter a the first of two positive integers to create obj2 and test
obj2.equals(MyInteger obj3) or to move on to next part of
program:
Enter a the second of two positive integers to create obj3 and test
obj2.equals(MyInteger obj3):
Enter a positive integer that will be placed into a char[] array to
demonstrate the MyInteger.parseInt(char[]):
Enter a positive integer that will be placed into a String to
demonstrate the MyInteger.parseInt(String):
Inputs
--- Keyboard/Console/Standard Input stdin ---
1
2
3
7
8
1
2
19
23
24
1
2
5
22
19
22
22
33
33
33
34
11
11
1
1
1
2
125
256
333
444
987
Outputs
--- Monitor/Console/Standard Output ---
Enter a positive integer to create a MyInteger object or to move
on to next part of program:MyInteger obj0 = new MyInteger(1);
obj0.getValue() = 1
obj0.isEven() = false
obj0.isOdd() = true
obj0.isPrime() = false
Enter a positive integer to create a MyInteger object or to move on
to next part of program:MyInteger obj0 = new MyInteger(2);
obj0.getValue() = 2
obj0.isEven() = true
obj0.isOdd() = false
obj0.isPrime() = true
Enter a positive integer to create a MyInteger object or to move on
to next part of program:MyInteger obj0 = new MyInteger(3);
obj0.getValue() = 3
obj0.isEven() = false
obj0.isOdd() = true
obj0.isPrime() = true
Enter a positive integer to create a MyInteger object or to move on
to next part of program:MyInteger obj0 = new MyInteger(7);
obj0.getValue() = 7
obj0.isEven() = false
obj0.isOdd() = true
obj0.isPrime() = true
Enter a positive integer to create a MyInteger object or to move on
to next part of program:MyInteger obj0 = new MyInteger(8);
obj0.getValue() = 8
obj0.isEven() = true
obj0.isOdd() = false
obj0.isPrime() = false
Enter a positive integer to create a MyInteger object or to move on
to next part of program:Enter a positive integer to test static
isXXX(int) methods or to move on to next part of
program:MyInteger.isEven(1) = false
MyInteger.isOdd(1) = true
MyInteger.isPrime(1) = false
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:MyInteger.isEven(2) = true
MyInteger.isOdd(2) = false
MyInteger.isPrime(2) = true
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:MyInteger.isEven(19) = false
MyInteger.isOdd(19) = true
MyInteger.isPrime(19) = true
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:MyInteger.isEven(23) = false
MyInteger.isOdd(23) = true
MyInteger.isPrime(23) = true
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:MyInteger.isEven(24) = true
MyInteger.isOdd(24) = false
MyInteger.isPrime(24) = false
Enter a positive integer to test static isXXX(int) methods or to
move on to next part of program:Enter a positive integer to test
static isXXX(MyInteger) methods or to move on to next part of
program:MyInteger obj1 = new MyInteger(1);
obj1.getValue() = 1
MyInteger.isEven(obj1) = false
MyInteger.isOdd(obj1) = true
MyInteger.isPrime(obj1) = false
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:MyInteger obj1 = new
MyInteger(2);
obj1.getValue() = 2
MyInteger.isEven(obj1) = true
MyInteger.isOdd(obj1) = false
MyInteger.isPrime(obj1) = true
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:MyInteger obj1 = new
MyInteger(5);
obj1.getValue() = 5
MyInteger.isEven(obj1) = false
MyInteger.isOdd(obj1) = true
MyInteger.isPrime(obj1) = true
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:MyInteger obj1 = new
MyInteger(22);
obj1.getValue() = 22
MyInteger.isEven(obj1) = true
MyInteger.isOdd(obj1) = false
MyInteger.isPrime(obj1) = false
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:MyInteger obj1 = new
MyInteger(19);
obj1.getValue() = 19
MyInteger.isEven(obj1) = false
MyInteger.isOdd(obj1) = true
MyInteger.isPrime(obj1) = true
Enter a positive integer to test static isXXX(MyInteger) methods or
to move on to next part of program:Enter a the first of two
positive integers to create obj2 and test obj2.equals(int) or to
move on to next part of program:MyInteger obj2 = new
MyInteger(22);
obj2.getValue() = 22
Enter a the second of two positive integers to test
obj2.equals(int):obj2.equals(22) = true
Enter a the first of two positive integers to create obj2 and test
obj2.equals(int) or to move on to next part of program:MyInteger
obj2 = new MyInteger(33);
obj2.getValue() = 33
Enter a the second of two positive integers to test
obj2.equals(int):obj2.equals(33) = true
Enter a the first of two positive integers to create obj2 and test
obj2.equals(int) or to move on to next part of program:MyInteger
obj2 = new MyInteger(33);
obj2.getValue() = 33
Enter a the second of two positive integers to test
obj2.equals(int):obj2.equals(34) = false
Enter a the first of two positive integers to create obj2 and test
obj2.equals(int) or to move on to next part of program:Enter a the
first of two positive integers to create obj2 and test
obj2.equals(MyInteger obj3) or to move on to next part of
program:MyInteger obj2 = new MyInteger(11);
obj2.getValue() = 11
Enter a the second of two positive integers to create obj3 and test
obj2.equals(MyInteger obj3):MyInteger obj3 = new
MyInteger(11);
obj3.getValue() = 11
obj2.equals(obj3) = true
Enter a the first of two positive integers to create obj2 and test
obj2.equals(MyInteger obj3) or to move on to next part of
program:MyInteger obj2 = new MyInteger(1);
obj2.getValue() = 1
Enter a the second of two positive integers to create obj3 and test
obj2.equals(MyInteger obj3):MyInteger obj3 = new
MyInteger(1);
obj3.getValue() = 1
obj2.equals(obj3) = true
Enter a the first of two positive integers to create obj2 and test
obj2.equals(MyInteger obj3) or to move on to next part of
program:MyInteger obj2 = new MyInteger(1);
obj2.getValue() = 1
Enter a the second of two positive integers to create obj3 and test
obj2.equals(MyInteger obj3):MyInteger obj3 = new
MyInteger(2);
obj3.getValue() = 2
obj2.equals(obj3) = false
Enter a the first of two positive integers to create obj2 and test
obj2.equals(MyInteger obj3) or to move on to next part of
program:Enter a positive integer that will be placed into a char[]
array to demonstrate the MyInteger.parseInt(char[]):MyInteger obj4
= new MyInteger(MyInteger.parseInt(char []);
obj4.getValue() = 125
obj4.isEven() = false
obj4.isOdd() = true
obj4.isPrime() = false
Enter a positive integer that will be placed into a char[] array to
demonstrate the MyInteger.parseInt(char[]):MyInteger obj4 = new
MyInteger(MyInteger.parseInt(char []);
obj4.getValue() = 256
obj4.isEven() = true
obj4.isOdd() = false
obj4.isPrime() = false
Enter a positive integer that will be placed into a char[] array to
demonstrate the MyInteger.parseInt(char[]):Enter a positive integer
that will be placed into a String to demonstrate the
MyInteger.parseInt(String):MyInteger obj5 = new
MyInteger(MyInteger.parseInt(String);
obj5.getValue() = 333
obj5.isEven() = false
obj5.isOdd() = true
obj5.isPrime() = false
Enter a positive integer that will be placed into a String to
demonstrate the MyInteger.parseInt(String):MyInteger obj5 = new
MyInteger(MyInteger.parseInt(String);
obj5.getValue() = 444
obj5.isEven() = true
obj5.isOdd() = false
obj5.isPrime() = false
Enter a positive integer that will be placed into a String to
demonstrate the MyInteger.parseInt(String):MyInteger obj5 = new
MyInteger(MyInteger.parseInt(String);
obj5.getValue() = 987
obj5.isEven() = false
obj5.isOdd() = true
obj5.isPrime() = false
Enter a positive integer that will be placed into a String to
demonstrate the MyInteger.parseInt(String):
In: Computer Science
Please use very basic level of bluej thanks (please dont use advance techniques )
Write a class House that represents a house. It should contain instance data: house number, street, town, year when the house was built. Define House’s constructor to accept and initialize all instance data. Include getter (accessor) and setter (mutator) methods for all instance data. Provide a toString method that returns one line description of the house as String. Provide method isHistoric() that returns a boolean indicating if the house was older than 50 from now or not.
Create a TestHouse class with main method in it. Within main method instantiate three House objects of your choice. At least one home should be historic. For each object invoke methods toString and isHistoric, and also invoke different pair of getter and setter methods. Provide appropriate print statements to explain the result of each invoked method to user.
In: Computer Science