Answer:
Software Updates, Computing Sources, No Coding, Relatively Inexpensive, Safeguards Data.
Explanation:
A variable that can have values only in the range 0 to 65535 is a :
a. Two-byte unsigned int.
b. Four-byte int.
c. Two-byte int.
d. Four-byte unsigned int.
Answer:
a.
Explanation:
Two bytes have 2 times 8 bits is 16 bits.
Max value that can be expressed is 2¹⁶-1 = 65535
Use the get_seconds function to work out the amount of seconds in 2 hours and 30 minutes, then add this number to the amount of seconds in 45 minutes and 15 seconds. Then print the result.
Answer:
Since the get_seconds function is not given, I'll implement it myself;
The full program (get_seconds and main) written in python is as follows:
def get_seconds(hour,minute,seconds):
seconds = hour * 3600 + minute * 60 + seconds
return seconds
time1 = get_seconds(2,30,0)
time2 = get_seconds(0,45,15)
result = time1 + time2
print(result)
Explanation:
The get_seconds defines hour, minute and seconds as its arguments
This line defines the get_seconds function
def get_seconds(hour,minute,seconds):
This line calculates the second equivalent of the time passed to the function
seconds = hour * 3600 + minute * 60 + seconds
This line returns the the calculated seconds equivalent of time
return seconds
The main starts here
This line calculates the number of seconds in 2 hours and 30 minutes
time1 = get_seconds(2,30,0)
This line calculates the number of seconds in 45 minutes and 15 seconds
time2 = get_seconds(0,45,15)
This line adds both together
result = time1 + time2
This line prints the result
print(result)
What is displayed by the alert dialog box after the following code executes? var name = "Donny,Duck"; var index = name.indexOf(","); var lastName = name.substr(index + 1, name.length - 1);; alert("Last name: " + lastName);
Answer:
Last name: Duck
Explanation:
explanation is provided in the attached document.
When you create a .wim file instead of a .vhdx file, how is the .wim file used to deploy the Nano Server
Answer:
the server will atomaticly detect
Explanation:
not worry
What is the absolute pathname of the YUM configuration file? REMEMBER: An absolute pathname begins with a forward slash
Answer:
/etc/yum.conf
Explanation:
The absolute pathname for YUM is /etc/yum.conf. The configuration file For yum and related utilities can be found there. The file has one compulsory section, and this section can be used to place Yum options with global effect, it could also have one or more sections, that can enable you to set repository-specific options.
.
How does an employer judge a candidate?
The employer judge's the candidate's blank
for a job
Answer:
The first thing that is judged in the interview is the self confidence. If a person is self confident he is better able to express himself. The employer wants a candidate who has potential to bring good to the organization.
Explanation:
The employer for enthusiasm in the candidate to work passionately. He also considers relevant skills and expertise and relevant knowledge of work. The qualification also matters. It is important for a candidate to read the person specifications carefully before applying for a job. There can be certain tests conducted by employer during the interview process to identify the candidates potential and how he reacts in certain situations.
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a file. The program should output the unique words and their frequencies in alphabetical order. Variations are to track sequences of two words and their frequencies, or n words and their frequencies.
Below is an example file along with the program input and output:
example.txt
I AM SAM I AM SAM SAM I AM
Enter the input file name: example.txt
AM 3
I 3
SAM 3
Answer:
I am writing a Python program.
def concordance(filename): # function that takes a file name as parameter and returns the concordance for that file
file = open(filename,"r") #opens file in read mode
unique={} #creates and empty list
for word in file.read().split(): #loops through every word in the file
if word in unique: # if words is already present in the list
unique[word] += 1 #add 1 to the count of the existing word
else: #if word is not present in the list
unique[word] = 1 #add the word to the list and add 1 to the count of word
file.close(); # close the file
for x in sorted(unique): #sort the list and displays words with frequencies
print(x, unique[x]); #prints the unique words and their frequencies in alphabetical order
#prompts user to enter the name of the file
file_name=input('Enter the input file name: ')
concordance(file_name) #calls concordance method by passing file name to it
Explanation:
The program has a function concordance that takes a text file name as parameter and returns a list of unique words and their frequencies.
The program first uses open() method to open the file in read mode. Here "r" represents the mode. Then creates an empty list named unique. Then the for loop iterates through each word in the file. Here the method read() is used to read the contents of file and split() is used to return these contents as a list of strings. The if condition inside the loop body checks each word if it is already present in the list unique. If the word is present then it adds 1 to the count of that word and if the word is not already present then it adds that unique word to the list and assign 1 as a count to that word. close() method then closes the file. The second for loop for x in sorted(unique): is used to display the list of unique words with their frequencies. sorted() method is used to sort the list and then the loop iterates through each word in the list, through x, which acts like an index variable, and the loop displays each word along with its frequency.
Which best describes the purpose of LoJack on a computer
Answer:The purpose of the lo jack on a computer to the lock and delete files on the computer devices.
Explanation:The lo jack on a computer to locate all the lock and delete files.
lo jack can provides the computer on the passwords that contains different levels of the bios access.
lo jack perform on the computer operating system provides on the boot only the trusted by the computer operating system.
Lo jack computer on the function is used to the published the exam answers on the websites.
Lo jack insures to the data into hard drives to the correct computer password.
A continuous-time periodic signal x(t) is real valued and has a fundamental period T = 8. The nonzero Fourier series coefficients for x(t) are specified as
a_1 = a*_-1 = j, a_5 = a_-5 = 2.
Express x(t) in the form
x(t) = sigma^infinity_k=0 A_k cos(W_k t + phi_k).
Answer:
x(t) = −2 cos ( [tex]\frac{\pi }{4}t[/tex] − [tex]\frac{\pi }{2}[/tex] ) + 4 cos ( [tex]\frac{5\pi }{4}t[/tex] )
Explanation:
Given:
Fundamental period of real valued continuous-time periodic signal x(t) = T = 8
Non-zero Fourier series coefficients for x(t) :
a₁ = [tex]a^{*}_{-1}[/tex] = j
a₅ = [tex]a_{-5}[/tex] = 2
To find:
Express x(t) in the form
∞
x(t) = ∑ A[tex]_{k}[/tex] cos ( w[tex]_{k}[/tex] t + φ[tex]_{k}[/tex] )
[tex]_{k=0}[/tex]
Solution:
Compute fundamental frequency of the signal:
w₀ = 2 π / T
= 2 π / 8 Since T = 8
w₀ = π / 4
∞
∑ [tex]a_{k}e^{jw_{0}t }[/tex]
x(t) = k=⁻∞
= [tex]a_{1}e^{jw_{0} t} + a_{-1}e^{-jw_{0} t} + a_{5}e^{5jw_{0} t}+a_{-5}e^{-5jw_{0} t}[/tex]
= [tex]je^{j(\pi/4)t} - je^{-j(\pi/4)t} +2e^{(5\pi/4)t}+2e^{-(5\pi/4) t}[/tex]
= −2 sin ( [tex]\frac{\pi }{4}t[/tex] ) + 4 cos ( [tex]\frac{5\pi }{4}t[/tex] )
= −2 cos ( [tex]\frac{\pi }{4}t[/tex] − [tex]\frac{\pi }{2}[/tex] ) + 4 cos ( [tex]\frac{5\pi }{4}t[/tex] )
Complete the function ConvertToDecadesAndYears to convert totalYears to decades and years. Return decades and years using the TimeDecadesYears struct. Ex: 26 years is 2 decades and 6 years.
Answer:
It is a C++ program. The complete function ConvertToDecadesAndYears which takes totalYears as parameter and convert totalYears to decades and years is provided in the attached document.
Explanation:
The explanation is provided in the attached document.
The screenshot of the complete code along with its output is attached.
Assuming a Stop-and-Wait system, if the bandwidth-delay product of a channel is 500 Mbps and 1 bit takes 25 milliseconds to make the roundtrip, what is the bandwidth-delay product? If the data packets are 2500 bits in length, what is the utilization?
Answer:
Bandwidth delay product = 2500 Kbits
Utilization = 0.02%
Explanation:
We proceed as follows;
From the question, we are given that
band width = 500 Mbps
The bandwidth-delay product is = 500 x 10^6 x 25 x 10^-3
= 2500 Kbits
The system can send 12500 Kbits during the time it takes for the data to go from the sender to the receiver and then back again.
However, the system sends only 2500 bits.
The the link utilization =
2500/(12500 x 10^3) = 0.02%
Steve wants to take charge of his finances. To do so, he must track his income and expenditures. To accurately calculate his take-home pay, Steve must use his __________.
Answer:brain
Explanation:
to think
An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may:_______
a. have a redundancy.
b. get caught in an infinite loop.
c. suffer from indefinite postponement.
d. issue a compiler error.
Answer:
c. suffer from indefinite postponement.
Explanation:
Algorithm is a set of rules that are followed in calculations or other problem solving operation by a computer. An algorithm may execute for unknown amount of time and it may suffer indefinite postponement. Algorithm depends on random numbers and it can execute continuously.
what happens if a spelling checker does not have a suggestion for a misspelled word?
if the bandwidth-delay product of a channel is 500 Mbps and 1 bit takes 25 milliseconds to make the roundtrip, what is the bandwidth-delay product
Answer:
2500 kb
Explanation:
Here, we are to calculate the bandwidth delay product
From the question, we are given that
band width = 500 Mbps
The bandwidth-delay product is = 500 x 10^6 x 25 x 10^-3
= 2500 Kbits
C create a class called Plane, to implement the functionality of the Airline Reservation System. Write an application that uses the Plane class and test its functionality. Write a method called Check In() as part of the Plane class to handle the check in process Prompts the user to enter 1 to select First Class Seat (Choice: 1) Prompts the user to enter 2 to select Economy Seat (Choice: 2) Assume there are only 5-seats for each First Class and Economy When all the seats are taken, display no more seats available for you selection Otherwise it displays the seat that was selected. Repeat until seats are filled in both sections Selections can be made from each class at any time.
Answer:
Here is the C++ program:
#include <iostream> //for using input output functions
using namespace std; //to identify objects like cin cout
class Plane{ //class Plane
private: // declare private data members i.e. first_class and eco_class
int first_class; //variable for first class
int eco_class; //variable declared for economy class
public: // public access modifier
Plane(){ //constructor to initialize values of first_class and eco_class
first_class=0; //initialized to 0
eco_class=0;} //initialized to 0
int getFirst(){ // class method to get data member first_class
return first_class;} //returns the no of reserved first class seats
int getEco(){ // class method to get data member eco_class
return eco_class;} //returns the no of reserved eco class seats
void CheckIn(){ //method to handle the check in process
int choice; //choice between first and economy class
cout<<"\nEnter 1 to select First Class Seat: "<<endl; //prompts user to enter 1 to reserve first class seat
cout<<"\nEnter 2 to select Economy Class Seat: "<<endl; //prompts user to enter 2 to reserve economy class seat
cin>>choice; //reads the choice from user
switch(choice){ // switch statement is used to handle the check in process
case 1: //to handle the first class seat reservation
if(getFirst()<5){ //if the seat is available and the seat limit has not exceed 5
first_class++; //add 1 to the first_class seat to count that a seat is reserved
cout<<"You reserved First class seat! ";} //display the message about successful seat reservation in first class
cout<<"\nNumber of first class seats reserved: "<<getFirst()<<endl;} //displays the number of seats already reserved
else{ //if all first class seats are reserved then display the following message
cout<<"No more seats available for you selection!"<<endl;
if(getEco()>=5 && getFirst()>=5){ //if all seats from first class and economy class are reserved display the following message
cout<<"All seats are reserved!"<<endl;
exit(1);}} //program exits
break;
case 2: //to handle the economy seat reservation
if(getEco()<5){ //if the seat is available and the seat limit has not exceed 5
eco_class++; //add 1 to the eco_class seat to count that a seat is reserved
cout<<"You reserved Economy class seat! "; //display the message about successful seat reservation in economy class
cout<<"\nNumber of Economy class seats reserved: "<<getEco()<<endl;} //displays the number of seats already reserved
else{ //if all economy class seats are reserved then display the following message
cout<<"No more seats available for you selection!"<<endl;
if(getEco()>=5 && getFirst()>=5){ //if all seats from first class and economy class are reserved display the following message
cout<<"All seats are reserved!"<<endl;
exit(1);}} //program exits
break;
default: cout<<"Enter a valid choice"<<endl; } } }; //if user enters anything other that 1 or 2 for choice then this message is displayed
int main(){ //start of main() function body
int select; // choice from first or economy class
Plane plane; //create an object of Plane class
cout<<"**************************"<<endl;
cout<<"Airline Reservation System"<<endl; //display this welcome message
cout<<"**************************"<<endl;
while(true){ // while loop executes the check in procedure
plane.CheckIn();} } //class CheckIn method of Plane classs using plane object to start with the check in process
Explanation:
The program is elaborated in the comments with each statement of the above code. The program has a class Plane that has a method CheckIn to handle the check in process. The user is prompted to enter a choice i.e. enter 1 to select First Class Seat and enter 2 to select Economy Seat. A switch statement is used to handle this process. If user enters 1 then the case 1 of switch statement executes which reserves a seat for the user in first class. If user enters 2 then the case 2 of switch statement executes which reserves a seat for the user in economy class.There are only 5 seats for each First Class and Economy. So when the limit of the seats reservation exceeds 5 then the no more seats available for you selection is displayed. If all the seats are taken in both the first and economy class then it displays the message All seats are reserved. If the user enters anything other than 1 or 2 then display the message Enter a valid choice. Whenever the user reserves one of first or economy class seats the relevant seat is incremented to 1 in order to count the number of seats being reserved. The program and its output are attached.
JavaScript
Code Example 4-1
var name = prompt("Enter the name to print on your tee-shirt");
while (name.length > 12) {
name = prompt("Too long. Enter a name with fewer than 12 characters.");
}
alert("The name to be printed is " + name.toUpperCase());
What will happen if the user enters Willy Shakespeare at the first prompt?
A. The user will be prompted to enter a different name.
B. The alert will display The name to be printed is " + name.toUpperCase().
C. The alert will display The name to be printed is WILLY SHAKESPEARE.
D. The alert will display The name to be printed is WILLY SHAKES.
Answer:
(a) The user will be prompted to enter a different name
Explanation:
Given code;
--------------------------------------------------------------------------------------------------------
var name = prompt("Enter the name to print on your tee-shirt");
while (name.length > 12) {
name = prompt("Too long. Enter a name with fewer than 12 characters.");
}
alert("The name to be printed is " + name.toUpperCase());
--------------------------------------------------------------------------------------------------------
=>The first line of the code prompts the user to enter some name to be printed on their tee-shirt, and the input from the user is saved in a variable called name.
=> In the while block, the name variable is checked. If the length of the value of the variable is greater than 12 then a new prompt that says "Too long. Enter a name with fewer than 12 characters" is displayed.
=> In the last line, if the name variable is checked and the length is less than 12, then an alert statement showing the name in uppercase is displayed with some prepended texts.
Now, if the user enters Willy Shakespeare at the first prompt, the while block will be executed since Willy Shakespeare has over 12 characters.
In other words, the prompt in the while block, asking the user to enter a different name will be displayed. i.e
"Too long. Enter a name with fewer than 12 characters"
Write a function named twoWordsV2 that has the same specification as Problem 1, but implement it using while and not using break. (Hint: provide a different boolean condition for while.) Since only the implementation has changed, and not the specification, for a given input the output should be identical to the output in Problem 1.
Answer:
I am writing a Python program. Here is the function twoWordsV2:
def twoWordsV2 (length,firstLetter):#definition of function which takes length of the first word and first letter of the second word as parameter and returns these two words in a list
word1 = "" # stores the first word
word2= "" #holds the second word
while(len(word1)!=length): # checks if the input word1 length is not equal to the specified length
word1 = input('A ' + str(length) + '-letter word please: ') #asks user to enter the input word1 of specified length
while(word2!=firstLetter): #checks if the first character of input word2 is not equal to the specified firstLetter character
word2 = input('A word beginning with ' + firstLetter+ ' please: ')#asks user to enter the input word2 begining with specified first letter
if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower():#second word may begin with either an upper or lower case instance of firstLetter
return [word1,word2] #return the two words in a list
#to check the working of the function use the following statement
print(twoWordsV2(4,'B')) #calls twoWordsV2 method by passing 4 (length) and B (first letter)
Explanation:
twoWordsV2 method has two parameters i.e length which is the length of the first word and firstLetter which is the first character of the the second word. This means the first word should be of specified length, and the second word should begin with a specified first letter. The function returns the two resultant words with the above specifications. These two words are displayed in a list. I will explain the working of the function with the help of an example:
Suppose length = 4 and firstLetter = 'B' and user enters "ok" as word1. input() method takes first word input from user.
The first while loop checks if the length of word1 i.e. ok is not equal to specified length i.e. 4. Length of word1 is checked using len function which returns 2 so length of word1 is 2. The loop condition is true because length of word1 i.e. 2 is not equal to specified length i.e. 4. So the body of the loop executes which displays this message:
A 4-letter word please:
Here notice that str(length) is changed to 4. This is because length=4 and str() converts this value into string.
So the above message keeps displaying until user enters a four letter word. Lets suppose user now enters "four". Now the while loop condition evaluates to false and the loop breaks. The program control moves to the next line which is a while loop.
The second while loop checks if the first character of input word2 is not equal to the specified firstLetter character. Suppose word2 = "apple" and firstLetter= 'B'
Now the loop condition evaluates to true because word2 is not equal to first letter B. Now the main part of this while loop is the if condition: if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower() This statement checks if the first index of the word2 is equal to firstLetter. The word2 can contain a capital B or a small B so if condition checks both the cases by using upper and lower methods that converts the firstLetter to upper or lower and then match with the first letter of word2 i.e. the letter at index 0 of the word2. If this condition evaluates to true then next return statement returns the word1 and word2 in a list otherwise the second while loop keep asking user to enter the word2 with starting letter to be firstLetter i.e. 'B'.
The screenshot of the program and its output is attached.
The function for the given problem is:
def twoWordsV2 (length,firstLetter):word1 = "" # stores the first wordword2= "" #holds the second word while(len(word1)!=length): word1 = input('A ' + str(length) + '-letter word please: ') while(word2!=firstLetter): word2 = input('A word beginning with ' + firstLetter+ ' please: ')if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower(): return [word1,word2] print(twoWordsV2(4,'B')) Brief Explanation:These 10 lines of code were written using the Python programming language and this was used to define, store and hold the function and then request input from the user, check if the given input was according to the required parameters, and then print the output.
Read more about python programming language here:
https://brainly.com/question/7015522
The program below counts the number of characters in a file, assuming the file is encoded as ASCII. Modify the program so that it counts the number of characters in a file encoded as UTF-8. CODE: #include #include typedef unsigned char BYTE; int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: ./count INPUT\n"); return 1; } FILE *file = fopen(argv[1], "r"); if (!file) { printf("Could not open file.\n"); return 1; } int count = 0; while (true) { BYTE b; fread(&b, 1, 1, file); if (feof(file)) { break; } count++; } printf("Number of characters: %i\n", count); }
Answer:
Coding is a skill where you take instructions (the steps in a task) and translate it into a language the computer understands since computers do not communicate like humans. They communicate in a language called BINARY and it is uses 0's and 1's. Coders write the instructions using a programming language.
Explanation:
Coding is a skill where you take instructions (the steps in a task) and translate it into a language the computer understands since computers do not communicate like humans. They communicate in a language called BINARY and it is uses 0's and 1's. Coders write the instructions using a programming language.
1 #Write a function called phonebook that takes two lists as
2 #input:
3 #
4 # - names, a list of names as strings
5 # - numbers, a list of phone numbers as strings
6 #
7 #phonebook() should take these two lists and create a
8 #dictionary that maps each name to its phone number. For
9 #example, the first name in names should become a key in
10 #the dictionary, and the first number in numbers should
11 #become the value corresponding to the first name. Then, it
12 #should return the dictionary that results.
13 #
14 #Hint: Because you're mapping the first name with the first
15 #number, the second name with the second number, etc., you do
16#not need two loops. For a similar exercise, check back on
17 #Coding Problem 4.3.3, the Scantron grading problem.
18 #
19 #You may assume that the two lists have the same number of #items: there will be no names without numbers or numbers
20 #without names.
21 #Write your function here!
25
26
27
28 #Below are some lines of code that will test your function
29 #You can change the value of the variable(s) to test your
30 #function wit h different inputs 2 If your function works correctly, this ill originally
31
32 #print (although the order of the keys may vary):
33| #('Jackie': '404-555-1234., 'Joshua': .678-555-5678., "Marguerite': '778-555-9012
35
36 name_list ['Jackie', Joshua', 'Marguerite']
37 number list-['484-555-1234, 678-555-5678 770-555-9812']
38 print (phonebook (name list, numberlist))
39
40
41
Answer:
I am writing a Python program.
def phonebook(names, numbers): #method phonebook that takes two parameters i.e a list of names and a list of phone numbers
dict={} #creates a dictionary
for x in range(len(names)): # loop through the names
dict[names[x]]=numbers[x] #maps each name to its phone number
return dict #return dictionary in key:value form i.e. name:number
#in order to check the working of this function, provide the names and numbers list and call the function as following:
names = ['Jackie', 'Joshua', 'Marguerite']
numbers = ['404-555-1234', '678-555-5678', '770-555-9012']
print(phonebook(names, numbers))
Explanation:
The program has a function phonebook() that takes two parameters, name which is a list of names and numbers that is a list of phone numbers.
It then creates a dictionary. An empty dictionary is created using curly brackets. A dictionary A dictionary is used here to maps a names (keys) phone numbers (values) in order to create an unordered list of names and corresponding numbers.
for x in range(len(names)):
The above statement has a for loop and two methods i.e. range() and len()
len method is used to return the length of the names and range method returns sequence of numbers just to iterate as an index and this loops keeps iterating until x exceeds the length of names.
dict[names[x]]=numbers[x]
The above statement maps each name to its phone number by mapping the first name with the first umber, the second name with the second number and so on. This mapping is done using x which acts like an index here to map first name to first number and so on. For example dict[names[1]]=numbers[1] will map the name (element) at 1st index of the list to the number (element) at 1st index.
return dict retursn the dictionary and the format of dictionary is key:value where key is the name and value is the corresponding number.
The screenshot of the program and its output is attached.
What is displayed in the alert dialog box after the following code is executed? var scores = [70, 20, 35, 15]; scores[scores.length] = 40; alert("The scores array: " + scores);
Answer:
The scores array: 70,20,35,15,40
Explanation:
I will explain the code line by line:
var scores = [70, 20, 35, 15];
The above statement declares and assigns values to an array named scores
scores[scores.length] = 40;
The above statement uses length to set the length of the scores array. It sets the last element of the scores array to 40. So this means 40 is set as the last element of scores.
scores.length returns the length of the scores array i.e. 4 as there are 4 elements in scores array 70,20,35,15
So the statement becomes:
scores[4] = 40;
This assigns value 40 to the 4th index of the scores array. Do not confuse 4th index with 4th element of the array because array element location starts from 0. So scores[4] does not mean 4th element but scores[4] means 4th index position of scores array. This makes 5th element of scores. So set the element 40 as 5th element at 4th index of scores.
alert("The scores array: " + scores);
This displays an alert box with the following message:
The scores array: 70,20,35,15,40
A car can move, a crystal can grow, a fire alarm is sensitive and they are classified as non-living things. Explain?
Answer:
They are all controlled by something else. A car is controlled by humans. A crystal grows due to the temperature and climate. A fire alarm only rings when it senses smoke, which is caused by something else, usually humans.
What is the best way to show a complex data chart in word?
Answer:just do it
Explanation:
How different quantities are determined
If the current date is Monday, February 26, 2017, what will be displayed by the alert dialog box after the following code executes? var thisDay = new Date(); alert(thisDay.toDateString());
Answer:
Mon Feb 26 2017
Explanation:
Since the current date is considered as Monday, February 26, 2017, thisDay will be set to that value.
The toDateString() method returns the first three letters of the name of the day (The first letter is capitalized), the first three letters of the name of the month (The first letter is capitalized), the day of the month as an integer, and the year as an integer (There are spaces between all)
Complete the below method, isPalindrome(), that takes in a String and returns a boolean. The boolean should be true if the String is a palindrome, i.e., the String is the same if read forwards or in reverse. For example, "racecar" is a palindrome. The method should return false if the String is not a palindrome. Note: any single-letter word is considered a palindrome.
public class StringMethod {
public static boolean isPalindrome(String word) {
//TODO: Complete this method
}
}
Answer:
public static boolean isPalindrome(String word) {
//TODO: Complete this method
String reverse = "";
for (int i = (word.length()-1); i>=0; i--) {
if(word.charAt(i)!=' '){
reverse+=word.charAt(i);
}
}
String without_space = word.replaceAll(" ", "");
return reverse.equals(without_space);
}
Methods are collections of named code blocks, that are executed when called or evoked.
The isPalindrome method written in Java, where comments are used to explain each line is as follows
//This defines the method
public static boolean isPalindrome(String word) {
//This removes all the spaces in the word
String newStr = word.replaceAll(" ", "");
//This initializes an empty string
String rev = "";
//This iterates through the word, in reverse order
for (int i = (word.length()-1); i>=0; i--) {
//This gets all the characters in the string (without the space)
if(word.charAt(i)!=' '){
rev+=word.charAt(i);
}
}
//This returns true or false
return reverse.equals(newStr);
}
Read more about methods at:
https://brainly.com/question/19360941
What will be displayed after code corresponding to the following pseudocode is run? Main Set OldPrice = 100 Set SalePrice = 70 Call BigSale(OldPrice, SalePrice) Write "A jacket that originally costs $ " + OldPrice Write "is on sale today for $ " + SalePrice End Program Subprogram BigSale(Cost, Sale As Ref) Set Sale = Cost * .80 Set Cost = Cost + 20 End Subprogram
Answer:
A jacket that originally costs $ 100 is on sale today for $ 80
Explanation:
Main : From here the execution of the program begins
Set OldPrice = 100 -> This line assigns 100 to the OldPrice variable
Set SalePrice = 70 -> This line assigns 70to the SalePrice variable
Call BigSale(OldPrice, SalePrice) -> This line calls BigSale method by passing OldPrice and SalePrice to that method
Write "A jacket that originally costs $ ", OldPrice -> This line prints/displays the line: "A jacket that originally costs $ " with the resultant value in OldPrice variable that is 100
Write "is on sale today for $ ", SalePrice -> This line prints/displays the line: "is on sale today for $ " with the resultant value in SalePrice variable that is 80
End Program -> the main program ends
Subprogram BigSale(Cost, Sale As Ref) -> this is a definition of BigSale method which has two parameters i.e. Cost and Sale. Note that the Sale is declared as reference type
Set Sale = Cost * .80 -> This line multiplies the value of Cost with 0.80 and assigns the result to Sale variable
Set Cost = Cost + 20 -> This line adds 20 to the value of Cost and assigns the result to Cost variable
End Subprogram -> the method ends
This is the example of call by reference. So when the method BigSale is called in Main by reference by passing argument SalePrice to it, then this call copies the reference of SalePrice argument into formal parameter Sale. Inside BigSale method the reference &Sale is used to access actual argument i.e. SalePrice which is used in BigSale(OldPrice, SalePrice) call. So any changes made to value of Sale will affect the value of SalePrice
So when the method BigSale is called two arguments are passed to it OldPrice argument and SalePrice is passed by reference.
The value of OldPrice is 100 and SalePrice is 70
Now when method BigSale is called, the reference &Sale is used to access actual argument SalePrice = 70
In the body of this method there are two statements:
Sale = Cost * .80;
Cost = Cost + 20;
So when these statement execute:
Sale = 100 * 0.80 = 80
Cost = 100 + 20 = 120
Any changes made to value of Sale will affect the value of SalePrice as it is passed by reference. So when the Write "A jacket that originally costs $ " + OldPrice Write "is on sale today for $ " + SalePrice statement executes, the value of OldPrice remains 100 same as it does not affect this passed argument, but SalePrice was passed by reference so the changes made to &Sale by statement in method BigSale i.e. Sale = Cost * .80; has changed the value of SalePrice from 70 to 80 because Sale = 100 * 0.80 = 80. So the output produced is:
A jacket that originally costs $ 100 is on sale today for $ 80
The even_numbers function returns a space-separated string of all positive numbers that are divisible by 2, up to and including the maximum that's passed into the function. For example, even_numbers(6) returns “2 4 6”. Fill in the blank to make this work.
def even_numbers(maximum):
return_string = "" for x in ___: return_string += str(x) + " " return
return_string.strip() print(even_numbers(6)) # Should be 2 4 6 print(even_numbers(10)) # Should be 2 4 6 8 10 print(even_numbers(1)) # No numbers displayed print(even_numbers(3)) # Should be 2 print(even_numbers(0)) # No numbers displayed
Answer:
The correct form of the program in python is as follows
def even_numbers(maximum):
return_string = ""
for x in range(1,maximum+1):
if x % 2 == 0:
return_string+=str(x)+" "
return return_string.strip()
Explanation:
This line defines the method
def even_numbers(maximum):
This line initializes return_string to an empty string
return_string = ""
This line iterates through variable maximum
for x in range(1,maximum+1):
This line checks if the current number is even
if x % 2 == 0:
If yes, the string is updated
return_string+=str(x)+" "
This line returns the full string of even numbers
return return_string.strip()
When the method is tested with any of the following, it gives the desired result
print(even_numbers(6)), print(even_numbers(10)), print(even_numbers(1)), print(even_numbers(3)) and print(even_numbers(0))
Jason has a part time job in the office of a construction company and is also a student at a community college. He often works on his homework during times when he is not busy at work because the office computer contains the software he needs to do his assignments and he hasn't been able to afford to purchase the software for his own personal computer. Which of these unacceptable uses typically included in a user access policy might he most likely be engaging in?
Complete Question:
Jason has a part time job in the office of a construction company and is also a student at a community college. He often works on his homework during times when he is not busy at work because the office computer contains the software he needs to do his assignments and he hasn't been able to afford to purchase the software for his own personal computer. Which of these unacceptable uses typically included in a user access policy might he most likely be engaging in?
1.Using the network to download software for personal use
2.Disclosing personal information about employees
3.Copying of copyrighted material
4.Using a network account for a purpose not specified by the owner’s job description
Answer:
4.Using a network account for a purpose not specified by the owner’s job description
Explanation:
The office computer is meant to be used for the owner's purpose only. By using the office computer to do his homework, even at a free hour, Jason is still violating his employer's asset for selfish purpose. Jason could obtain permission from his manager to use the office computer for his homework for a temporary period, until he could "afford to purchase the software for his own personal computer." The official permission can exempt him from being penalized for the violation. A written permission is more ideal in this case.
1| def saveUserProfile(firstName, lastName, age, height, country):
2| filename = lastName + firstName + ".txt"
3| outputFile = open(filename, "w")
4| print(lastName, file = outputFile)
5| print(firstName, file = outputFile)
6| print(country, file = outputFile)
7| print(height, file = outputFile)
8| print(age, file = outputFile)
9| outputFile.close()
Above is a function that takes five pieces of information about a user and saves that data to a file. We'll assume firstName, lastName, and country are strings, age is an integer, and height (expressed in meters) is a float.
Assume we call the function above with this line of code:
saveUserProfile("David", "Joyner", 30, 1.8, "USA")
After the function runs, what is name of the file that is created?
a. What is written on line 1 of that file? If there is no line 1 or if line 1 is blank, enter Nothing.
b. What is written on line 2 of that file? If there is no line 2 or if line 2 is blank, enter Nothing.
c. What is written on line 3 of that file? If there is no line 3 or if line 3 is blank, enter Nothing.
d. What is written on line 4 of that file? If there is no line 4 or if line 4 is blank, enter Nothing.
e. What is written on line 5 of that file? If there is no line 5 or if line 5 is blank, enter Nothing.
Answer:
Joyner
David
USA
1.8
30
Explanation:
def saveUserProfile(firstName, lastName, age, height, country):
This is the definition of function named saveUserProfile which accepts the following parameters:
firstNamelastNameageheightcountryfilename = lastName + firstName + ".txt"
When the file is created it will be named as the lastName and firstName string combined with .txt as extension. For example if the lastName contains the name string Joyner and firstName contains the name David then the file created to be written is named as JoynerDavid.txt
outputFile = open(filename, "w")
This statement uses open() method in write mode and uses outputFile object to access the file. "w" represents write mode i.e. file is opened in write mode to write on it.
a) Joyner is written on line 1 of that file because of the following statement of above function:
print(lastName, file = outputFile)
This statement prints the string stored in lastName i.e. Joyner. Here outputFile opens the file in "w" write mode and writes the last name to the first line of the file.
b) David is written on line 2 of that file because of the following statement of above function:
print(firstName, file = outputFile)
This statement prints the string stored in firstName i.e. David. Here outputFile opens the file in "w" write mode and writes the first name to the second line of the file.
c) USA is written on line 3 of that file because of the following statement of above function:
print(country, file = outputFile)
This statement prints the data stored in country i.e. USA. Here outputFile opens the file in "w" write mode and writes the country name to the third line of the file.
d) 1.8 is written on line 4 of that file because of the following statement of above function:
print(height, file = outputFile)
This statement prints the value stored in height i.e. 1.8. Here outputFile opens the file in "w" write mode and writes the height value to the fourth line of the file.
e) 30 is written on line 5 of that file because of the following statement of above function:
print(age, file = outputFile)
This statement prints the value stored in age parameter of function saveUserProfile i.e. 30. Here outputFile opens the file in "w" write mode and writes the age value to the fifth line of the file.
QUESTION 6 Which of the following is a class A IPv4 address? a. 118.20.210.254 b. 183.16.17.30 c. 215.16.17.30 d. 255.255.0.0
Answer:
a. 118.20.210.254
Explanation:
Here are the few characteristics of Class A:
First bit of the first octet of class A is 0.
This class has 8 bits for network and 24 bits for hosts.
The default sub-net mask for class A IP address is 255.0.0.0
Lets see if the first bit of first octet of 118.20.210.254 address is 0.
118 in binary (8 bits) can be represented as : 1110110
To complete 8 bits add a 0 to the left.
01110110
First bit of the first octet of class A is 0 So this is class A address.
For option b the first octet is : 183 in the form of bits = 10110111 So it is not class A address
For option c the first octet is 215 in the form of bits = 11010111 So it is not class A address
For option d the first octet is 255 in the form of bits = 11111111. The first bit of first octet is not 0 so it is also not class A address.