Answer:
Explanation:
The following code is written in Java, it uses the scanner import to take in a string from the user. Then it uses the string builder import to use the input string and reverse it. Finally outputting the reversed string. The output can be seen in the attached picture below.
import java.util.Scanner;
class Brainly
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a string: ");
String answer = in.nextLine();
StringBuilder sb=new StringBuilder(answer);
sb.reverse();
System.out.println("Reversed: \n" + sb.toString());
}
}
In the following cell, we've loaded the text of Pride and Prejudice by Jane Austen, split it into individual words, and stored these words in an array p_and_p_words. Using a for loop, assign longer_than_five to the number of words in the novel that are more than 5 letters long. Hint: You can find the number of letters in a word with the len function.
Answer:
Explanation:
Since the array is not provided, I created a Python function that takes in the array and loops through it counting all of the words that are longer than 5. Then it returns the variable longer_than_five. To test this function I created an array of words based on the synapse of Pride and Prejudice. The output can be seen in the attached picture below.
def countWords(p_and_p_words):
longer_than_five = 0
for word in p_and_p_words:
if len(word) > 5:
longer_than_five += 1
return longer_than_five
what are the events?
Answer:
a thing that happens or takes place, especially one of importance.
Using a loop and indexed addressing, write code that rotates the members of a 32-bit integer array forward one position. The value at the end of the array must wrap around to the ?rst position. For example, the array [10,20,30,40] would be transformed into [40,10,20,30].
//begin class definition
public class Rotator{
//main method to execute the program
public static void main(String []args){
//create and initialize an array with hypothetical values
int [] arr = {10, 20, 30, 40};
//create a new array that will hold the rotated values
//it should have the same length as the original array
int [] new_arr = new int[arr.length];
//loop through the original array up until the
//penultimate value which is given by 'arr.length - 1'
for(int i = 0; i < arr.length - 1; i++ ){
//at each cycle, put the element of the
//original array into the new array
//one index higher than its index in the
//original array.
new_arr[i + 1] = arr[i];
}
//Now put the last element of the original array
//into the zeroth index of the new array
new_arr[0] = arr[arr.length - 1];
//print out the new array in a nice format
System.out.print("[ ");
for(int j = 0; j < new_arr.length; j++){
System.out.print(new_arr[j] + " ");
}
System.out.print("]");
}
}
Sample Output:[ 40 10 20 30 ]
Explanation:The code above is written in Java. It contains comments explaining important parts of the code. A sample output has also been provided.
Whatever programming language you use will ultimately need to be translated into binary in order for the computer to understand it.
a. True
b. False
Answer:
Javascript:
function translate(what) {
if (what) {
return 1;
} else if (!what) {
return 0;
}
}
translate(true);
Explanation:
True is 1;
False is 0;