Write a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file (directory.txt) that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. A driver program and templates have been created for you.

Answers

Answer 1

Answer:

Here is the JAVA program:

Items.java

public class Item {  // Item class

private String name, ph_num;  // class data members name to hold the name and ph_num stores the telephone numbers

public Item(String fullName, String PhoneNo){  //constructor of Item class , so fields full name and ph_num can be initialized when the object is created

name = fullName;  // holds the name field

ph_num = PhoneNo;}  //holds the telephone number

public String getFullName(){  // accessor method to get access to the name field

return name;}  //returns the name from directory

public String getPhoneNo(){  //accessor method to get access to the ph_nujm field

return ph_num; } } //returns the telephone number

Explanation:

LookupTable.java

public class LookupTable{  //class name

private ArrayList<Item> data;  // dynamic array list named data of Item class. This array list stores the names and telephone numbers from file

public LookupTable(){  //default constructor

data = new ArrayList<Item>();}  // creates an array list of Item type which holds the names and phone numbers

public void read(Scanner in){  // Scanner class object is created and this class is used to read input and the method reads the names and phone numbers

while(in.hasNext()){  // the loop moves through each line of the file. scanner class method hasNext checks for the tokens in the input

String name = in.nextLine();  // scans for the name in the input

String ph_num = in.nextLine();  //scans for the phone numbers in the input

data.add(new Item(name, ph_num));}}  // adds the names and phone number in to the Array list

public String lookup(String k){  //method looks up for an item in the table.  param k is the key to find . returns the value with the given key, or null if no       such item was found

String result = null;  //result initialized to to null

for(Item item: data){  //creates Item object and traverses the array list for each item i.e. name or phone numbers

if(k.equals(item.getFullName())){  //access the getFullName method through object item and checks if that name matches the key to find.

result = item.getPhoneNo();}}  //gets the corresponding phone number and assigns it to result variable

return result;}  //returns the result containing the phone number

public String reverseLookup(String v){  //Looks up an item in the table. param v is the value to find . returns the key with the given value, or null if no  such item was found. This method performs the lookup through phone number

String result = null;  //result is set to null to start

for(Item item: data){  //Traversing list through the for each item in data  

if(v.equals(item.getPhoneNo())){  //if the value of v is equal to the phone number accessed by using accessor method and object item

result = item.getFullName();}}  //accesses the corresponding name of that phone number and assigns it to the result

return result;}}  //returns the result                                

The data from directory file which contains the number and names. The LookupTable class has a method lookup which handles the lookups by names and the method reverseLookup that handles the lookups by phone number.  

Write A Telephone Lookup Program. Read A Data Set Of 1,000 Names And Telephone Numbers From A File (directory.txt)
Write A Telephone Lookup Program. Read A Data Set Of 1,000 Names And Telephone Numbers From A File (directory.txt)
Write A Telephone Lookup Program. Read A Data Set Of 1,000 Names And Telephone Numbers From A File (directory.txt)
Write A Telephone Lookup Program. Read A Data Set Of 1,000 Names And Telephone Numbers From A File (directory.txt)
Write A Telephone Lookup Program. Read A Data Set Of 1,000 Names And Telephone Numbers From A File (directory.txt)

Related Questions

In Network Address and Port Translation (NAPT), which best describes the information used in an attempt to identify the local destination address?

Answers

Answer:

Hello your question lacks the required options here are the options

source IP and destination IPsource IP and destination portsource IP and source portsource port and destination IPsource port and destination port

answer : source IP and destination port

Explanation:

The information that is used in an attempt to identify the local destination address is the source IP and destination port

source IP is simply the internet protocol address of a device from which an IP packet is sent to another device while destination port are the ports found in a destination device that receives IP packets from source ports  they are found in many internet applications  

Why is a DNS cache poisoning attack dangerous? Check all that apply. A. Errrr...it's not actually dangerous. B. It allows an attacker to redirect targets to malicious webservers. C. It allows an attacker to remotely controle your computer. D. It affects any clients querying the poisoned DNS server.

Answers

Answer:

(B) It allows an attacker to redirect targets to malicious webserver.

(D) It affects any clients querying the poisoned DNS server.

Explanation:

DNS cache poisoning is a serious type of attack that is designed to exploit the vulnerabilities inherent in a Domain Name Server (DNS) where a user is redirected from a real server to a fake one. It is also called DNS spoofing.

Normally, when your browser tries to visits a website through a given domain name, it goes through the DNS server. A DNS server maintains a list of domain names and their equivalent Internet Protocol addresses. This server (DNS) then responds to the request with one or more IP addresses for the browser to reach the website through the domain name.

The computer browser then get to the intended website through the IP address.

Now, if the DNS cache is poisoned, then it has a wrong entry for IP addresses. This might be via hacking or a physical access to the DNS server to modify the stored information on it. Therefore, rather than responding with the real IP address, the DNS replies with a wrong IP address which then redirects the user to an unreal website.

Although they might not be able to control your computer remotely as long as you are not trying to visit a web page via the poisoned information, there are other dangers attached to this type of attack.

Once the DNS server has been poisoned, any client trying to query the server will also be affected since there is no direct way of knowing if the information received from the server is actually correct.

Description:
Create a program that converts the number of miles that you walked on a hike to the number of feet that you walked.
Console:
Hike Calculator
How many miles did you walk?: 4.5
You walked 23760 feet.
Continue? (y/n): y
How many miles did you walk?: 2.5
You walked 13200 feet.
Continue? (y/n): n
Bye!
Specifications:
The program should accept a float value for the number of miles.
Store the code that gets user input and displays output in the main function.
There are 5280 feet in a mile.
Store the code that converts miles to feet in a separate function. This function should return an int value for the number of feet.
Assume that the user will enter a valid number of miles.

Answers

Answer:

The programming language is not stated (I'll answer using C++)

#include <iostream>

using namespace std;

int convert(float miles)

{

   return miles * 5280;

}

int main() {

   cout<<"Console:"<<endl;

   cout<<"Hike Calculator"<<endl;

   float miles;

   char response;

   cout<<"How many miles did you walk?. ";

   cin>>miles;

   cout<<"You walked "<<convert(miles)<<" feet"<<endl;

   cout<<"Continue? (y/n): ";

   cin>>response;

   while(response == 'y')

   {

   cout<<"How many miles did you walk?. ";

   cin>>miles;

   cout<<"You walked "<<convert(miles)<<" feet"<<endl;

   cout<<"Continue? (y/n): ";

   cin>>response;

   }

   cout<<"Bye!";

   return 0;

}

Explanation:

Here, I'll explain some difficult lines (one after the other)

The italicized represents the function that returns the number of feet

int convert(float miles)

{

   return miles * 5280;

}

The main method starts here

int main() {

The next two lines gives an info about the program

   cout<<"Console:"<<endl;

   cout<<"Hike Calculator"<<endl;

   float miles;

   char response;

This line prompts user for number of miles

   cout<<"How many miles did you walk?. ";

   cin>>miles;

This line calls the function that converts miles to feet and prints the feet equivalent of miles

   cout<<"You walked "<<convert(miles)<<" feet"<<endl;

This line prompts user for another conversion

   cout<<"Continue? (y/n): ";

   cin>>response;

This is an iteration that repeats its execution as long as user continue input y as response

   while(response == 'y')

   {

   cout<<"How many miles did you walk?. ";

   cin>>miles;

   cout<<"You walked "<<convert(miles)<<" feet"<<endl;

   cout<<"Continue? (y/n): ";

   cin>>response;

   }

   cout<<"Bye!";

? Question
Which term describes a population's attitudes and beliefs?
demographics
infographics
psychographics
geographics
psychgraphics
geographics​

Answers

Answer:

psychographics

Explanation:

The study of people according to their attitudes, aspirations and other psychological criteria

An admission charge for The Little Rep Theater varies according to the age of the person. Develop a solution to print the ticket charge given the age of the person. The charges are as follows:

a. Over 55: $10.00
b. 21-54: $15.00
c. 13-20: $10.00
d. 3-12: $5.00
e. Under 3: Free

Use a Multiple Alternative IF Statement

Answers

Answer:

age = int(input("Enter your age: "))

charge = 0

if age > 55:

   charge = 10

if 21 <= age <= 54:

   charge = 15

if 13 <= age <= 20:

   charge = 10

if 3 <= age <= 12:

   charge = 5

if 0 <= age < 3:

   charge = 0

   

print(charge)

Explanation:

*It is in Python.

Ask the user for the age

Check the each given range and set the charge accordingly using if statements

Print the charge

_____ are networks that learn and are capable of performing tasks that are difficult with conventional computers.

Answers

Answer:

Artificial Neural

Explanation:

An artificial neural is the piece of a computing system designed to simulate the way the human brain analyzes and processes information. It is the foundation of artificial intelligence.

Programming Challenge: Test Average CalculatorUsing a variable length array, write a C program that asks the user to enter test scores.Then, the program should calculate the average, determine the lowest test score, determine the letter grade, and display all three.

Answers

Answer:

well you could use variables in C and display them

Explanation:

Write a program that reads ten integers, and then display the number of even numbers and odd numbers. Assume that the input ends with 0. Here is the sample run of the program

Answers

Answer:

I am writing  a JAVA program. Let me know if you want this program in some other programming language.

import java.util.Scanner;  // class to take input from user

class EvenOddNum{  //class name

   static void EvenOdd(int array[]) {  //function that takes an array as input and displays number of even numbers and odd numbers

       int even = 0;  // counts even numbers      

       int odd = 0;   //counts odd numbers

       for(int i = 0 ; i < array.length-1 ; i++){  //loop through the array elements till the second last array element

           if ((array[i] % 2) == 1) {  // if the element of array is not completely divisible by 2 then this means its an odd  number

               System.out.println(array[i]+" = odd");  //display that element to be odd

               odd++ ; }  //adds 1 to the count of odd every time the program reads an odd number

           else{  // if above IF condition evaluates to false then the number is an even number

                System.out.println(array[i]+" = even"); //display that element to be odd

                even++ ; } }  //adds 1 to the count of odd every time the program reads an odd number

       System.out.println( "Number of even numbers = " + even);  //counts the total number of even integers in the array

       System.out.println( "Number of odd numbers = " + odd);    }   //counts the total number of odd integers in the array      

   public static void main (String[] args){  //start of main function body

       Scanner scan= new Scanner(System.in); //creates Scanner class object

       int [] integers = new int[10];  //declares an array named integers that stores 10 integers

       System.out.print("Enter numbers: ");  //prompts user to enter the integers

       for(int i = 0;i<integers.length;i++){  //loops to read the input integers

           integers[i] = scan.nextInt(); }  //scans and reads each integer value

       EvenOdd(integers);    } }  //calls function EvenOdd to display number of even and odd numbers

Explanation:

The program has a method EvenOdd that takes an array of integers as its parameter. It has two counter variables even and odd. even counts the number of even input integers and odd counts the number of odd input integers. The for loop iterates through each element (integer) of the array except for the last one. The reason is that it is assumed that the input ends with 0 so the last element i.e. 0 is not counted. So the loop iterates to length-1 of the array. The number is odd or even is determined by this if condition: if ((array[i] % 2) == 1) A number is even if it is divisible by 2 otherwise its odd. If the element of array is not completely divisible by 2 i.e. the remainder of the division is not 0 then the number is odd. The modulo operator is used which returns the remainder of the division of number by 2. Each time when an odd or even number is determined, the array[i]+" = even" or  array[i]+" = odd" is displayed on the output screen for each integer in the array. Here array[i] is the element of the array and even or odd depicts if that element is even or odd. The last two print statement display the total number of even and odd numbers in the array.

A company wants a recruiting app that models candidates and interviews; displays the total number of interviews on each candidate record; and defines security on interview records that is independent from the security on candidate records. What would a developer do to accomplish this task? Choose 2 answers


a. Create a roll -up summary field on the Candidate object that counts Interview records.

b. Create a master -detail relationship between the Candidate and Interview objects.

c. Create a lookup relationship between the Candidate and Interview objects.

d. Create a trigger on the Interview object that updates a field on the Candidate object.

Answers

Answer:

c. Create a lookup relationship between the Candidate and Interview objects.

d. Create a trigger on the Interview object that updates a field on the Candidate object.

Explanation:

Objects relationships is considered a form of field type that joins two or more objects together such that, after understanding objects and fields, it creates some form of bonding known as object relationships. This helps define security on interview records that is independent from the security on candidate records.

For an example, in a standard object like Account, where a sales representative opens an account, and has had interviews or chats with a few people at that account’s company, and as well made contacts with the likes of executives or IT managers and still stored those contacts’ information in salesforce.

Hence, what would a developer do to accomplish this task is to:

1. Create a lookup relationship between the Candidate and Interview objects.

2. Create a trigger on the Interview object that updates a field on the Candidate object.

Which statement is false?Structures are derived data types.Each structure definition must end with a semicolon.A structure can contain an instance of itself.Structures may not be compared using operators == and !=.

Answers

Answer:

A structure can contain an instance of itself

Explanation:

The statement which is known to be false out of the option given is that a structure may comprise or contain an instance of itself. Because to my knowledge, variables of diverse type are always most likely to attributed and contain by a structure.

It is worthy of note that object that aren't similar are utilize in constructing a structure. Another true statement about structure is that a semicolon usually end it's explanation.

1. Two TCP entities communicate across a reliable network. Let the normalized time to transmit a fixed length segment equal 1. Assume that the end-to-end propagation delay is 3 and that it takes 2 to deliver data from a received segment to the transport user. The receiver initially grants a credit of 7 segments. The receiver uses a conservative flow control policy and updates its credit allocation at every opportunity. What is the maximum achievable throughput

Answers

Answer:

The answer is "0.77"

Explanation:

The fixed-length segment value = 1  

The propagation time of one end to another end is = 3  

The Transfer power to move the consumer from the obtained segment = 2  

The second last sender assigns a loan = 7 segments  

The overall transmission time = 3+2+3   =  8  

The maximum throughput value is:

[tex]\to \frac{7}{(1 + 8)}\\\\ \to \frac{7}{9}\\\\\to 0.77[/tex]

Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 1000. The application should let the user specify how many random numbers the file will hold.

Answers

Answer:

The programming language is not stated;

I'll answer this question using python programming language

The program starts here (Lines written in bold are comments and are used for explanatory purpose)

#This line imports the random module into the program

import random

#This line prompts the user to enter the filename

filename = input("Enter file name: ")

#This line prompts the user to enter the number of random numbers to generate

num = int(input("Number of random  numbers: "))

#This line adjusts the filename to a .txt file

filename = filename+".txt"

#This line checks if the filename exists; if yes, it creates and open a new file and if otherwise, it uses the existing filr

f = open(filename,'a+')

#This line iterates through the number of random to generate

for i in range(1,num+1):

     #This line generates random number within the range of 1 to 1000

     n = random.randint(1,1000)

     #This line prints the generated random number to file

     print(n, file = f)

#This line closes the created file

f.close()

A technician wants to configure the inbound port of a router to prevent FTP traffic from leaving the LAN.
Which of the following should be placed on the router interface to accomplish this goal?
A. Static routes for all port 80 traffic
B. DHCP reservations for all /24 subnets
C. ACL for ports 20 and 21
D. MAC filtering using wildcards

Answers

Answer:

The technician will want to add ACL for ports 20 and 21

Explanation:

The FTP protocol by default will attempt to use 21 for TCP access and 20 for data access.  By enabling an Access Control List (ACL) on ports 20 and 21, the technician can prevent FTP traffic from leaving the network on the default ports.

Cheers.

#Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The function will look for the search string within the #target string. # #The function should return a string representing where in #the target string the search string was found: # # - If search string is at the very beginning of target # string, then return "Beginning". For example: # string_finder("Georgia Tech", "Georgia") -> "Beginning" # # - If search string is at the very end of target string, # then return "End". For example: # string_finder("Georgia Tech", "Tech") -> "End" # # - If search string is in target string but not at the # very beginning or very end, then return "Middle. For # example: # string_finder("Georgia Tech", "gia") -> "Middle" # # - If search string is not in target string at all, then # return "Not found". For example: # string_finder("Georgia Tech", "Idaho") -> "Not found" # #Assume that we're only interested in the first instance #of the search string if it appears multiple times in the #target string, and that search string is definitely #shorter than target string. # #Hint: Don't be surprised if you find that the "End" case #is the toughest! You'll need to look at the lengths of #both the target string and the search string. #Write your function here!

Answers

Answer:

I am writing a Python program:

def string_finder(target,search): #function that takes two parameters i.e. target string and a search string

   position=(target.find(search))# returns lowest index of search if it is found in target string

   if position==0: # if value of position is 0 means lowers index

       return "Beginning" #the search string in the beginning of target string

   elif position== len(target) - len(search): #if position is equal to the difference between lengths of the target and search strings

       return "End" # returns end

   elif position > 0 and position < len(target) -1: #if value of position is greater than 0 and it is less than length of target -1

       return "Middle" #returns middle        

   else: #if none of above conditions is true return not found

       return "not found"

#you can add an elif condition instead of else for not found condition as:

#elif position==-1    

#returns "not found"

#tests the data for the following cases      

print(string_finder("Georgia Tech", "Georgia"))

print(string_finder("Georgia Tech", "gia"))

print(string_finder("Georgia Tech", "Tech"))

print(string_finder("Georgia Tech", "Idaho"))

Explanation:

The program can also be written in by using string methods.

def string_finder(target,search):  #method definition that takes target string and string to be searched

       if target.startswith(search):  #startswith() method scans the target string and checks if the (substring) search is present at the start of target string

           return "Beginning"  #if above condition it true return Beginning

       elif target.endswith(search):  #endswith() method scans the target string and checks if the (substring) search is present at the end of target string

           return "End" #if above elif condition it true return End

       elif target.find(search) != -1:  #find method returns -1 if the search string is not in target string so if find method does not return -1 then it means that the search string is within the target string and two above conditions evaluated to false so search string must be in the middle of target string

           return "Middle"  #if above elif condition it true return End

       else:  #if none of the above conditions is true then returns Not Found

           return "Not Found"

Which are true of the Transmission Control Protocol (TCP)? Multiple answers: You can select more than one option A it supports full duplex communication B it has graceful connection shutdown C its connections are logical D its data is sent as a discrete messages E it is an end-to-end protocol

Answers

Answer:

A, B, C, D and E

Explanation:

Transmission Control protocol (TCP) is a protocol that describes how connections are made and maintained between devices in a network which will help applications in these devices communicate and transmit data.

The following are some of the features of TCP:

i. It supports full duplex communication: In other words, TCP allows for concurrent transmission of data in both directions.

ii. it has a graceful connection shutdown: TCP allows for graceful termination and closing of connection. This means that when there is no more data to be sent by any of the communicating devices, rather than just close connection from its end, it first informs the other device about its completion and asks if it's safe to close the connection. From there, if the other device then says it doesn't have any data to send either, they then reach a consensus to close the connection at their respective ends.

iii. Its connections are logical: TCP makes use of the reliability and flow control mechanisms which require that it initialize and maintain some status information for each stream of data. This status information containing sockets, sequence numbers and window sizes is called a logical connection.

iv. Data is sent as discrete messages: Like other discrete messages, the IP treats the data in TCP as discrete messages by placing them into the IP datagram and transmitting to the target host.

v. It is an end-to-end protocol: TCP governs the way data is transmitted between two devices at their respective ends to ensure reliable delivery. In other words, it is responsible for the transmission of data from a source to one or more destinations. It sits on the operating system of the source and also on the operating system(s) of the destination(s).

Describe in detail how TCP packets flow in the case of TCP handoff, along with the information on source and destination addresses in the various headers.

Answers

Answer:

Following are the answer to this question:

Explanation:

There will be several ways to provide it, although it is simpler to let another front side Will work out a three-way handshake or transfer packages to there with a Server chosen. Its application responds TCP packets with both the destination node of the front end.

The very first packet was sent to a computer as an option. Mention, even so, that perhaps the end of the queue end remains in the loop in this scenario. Rather than obtaining this information from the front end like in the primary healthcare services, you have the advantage of this capability: its selected server helps to generate TCP state.

Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times the character appears in the phrase. Ex: If the input is:

Answers

Answer:

The program written in python is as follows

def countchr(phrase, char):

     count = 0

     for i in range(len(phrase)):

           if phrase[i] == char:

                 count = count + 1

     return count

phrase = input("Enter a Phrase: ")

char = input("Enter a character: ")

print("Occurence: ",countchr(phrase,char))

Explanation:

To answer this question, I made use of function

This line defines function countchr

def countchr(phrase, char):

This line initializes count to 0

     count = 0

This line iterates through each character of input phrase

     for i in range(len(phrase)):

This line checks if current character equals input character

           if phrase[i] == char:

The count variable is incremented, if the above condition is true

                 count = count + 1

The total number of occurrence is returned using this line

     return count

The main method starts here; This line prompts user for phrase

phrase = input("Enter a Phrase: ")

This line prompts user for a character

char = input("Enter a character: ")

This line prints the number of occurrence of the input charcater in the input phrase

print("Occurence: ",countchr(phrase,char))

The machine has to be returned to the vendor for proper recycling. Which stage of the hardware lifecycle does this scenario belong to?

Answers

Answer:

Decommission/Recycle

Explanation:

This specific scenario that is being described belongs to the final stage of the hardware lifecycle known as Decommission/Recycle. This is when the asset in question has completed its function for an extended period of time and is no longer functioning at maximum efficiency and/or newer hardware has hit the market. Once in this stage, the hardware in question is either repaired or scrapped for resources that can be used to create newer products.

Some network applications defer configuration until a service is needed. For example, a computer can wait until a user attempts to print a document before the software searches for available printers.
What is the chief advantage of deferred configuration?

Answers

Answer:

The drivers wont be loaded and the deamons will not be running in the background unnecessarily, that makes the processes to run more faster

Explanation:

The chief advantage of deferred configuration or the advantage when some network applications defer configuration until a service is needed is that the drivers won't be loaded and the deamons will not be running in the background unnecessarily or when idle, that makes the processes to run more faster.

Network configuration is the activity which involves setting up a network's controls, flow and operation to assist the network communication of an organization or network owner.

Draw the BST where the data value at each node is an integer and the values are entered in the following order 36,22,10,44,42,16,25,3,23,24 solution

Answers

Answer and Explanation:

A BST is the short form for Binary Search Tree. It is a special type of binary tree data structure in which nodes are arranged in a particular order such that;

i. the left subtree of a particular node should always contain nodes whose key values are less than that of the key value of the node itself.

ii. the right subtree of a particular node should always contain nodes whose key values are greater than that of the key value of the node itself.

iii. the right and left subtrees should also be a binary search tree.

For the given set of data:

36,22,10,44,42,16,25,3,23,24;

The equivalent binary search tree is attached to this response.

As shown in the attachment:

i. the first data value (36) is the root node value.

ii. the second value (22) is less than the root node value (36), therefore, 22 goes to the left of the root node.

iii. the third value is 10. This is less than 36 and then also less than 22, so 10 goes to the left of 22.

iv. the fourth value is 44. This is greater than the root node value (36), therefore, 44 goes to the right of the root node.

v. the fifth value is 42. This is greater than the root value (36) so it is going to be positioned somewhere at the right of the root node. But it is less than the value (44) of the direct right node of the root node. Therefore, 42 goes to the left of the direct right (44) of the root node.

vi. the sixth value is 16. This is less than the root node value (36). So it is going to be positioned somewhere at the left of the root node. It is also less than the value (22) of the direct left node of the root node. So it is going to be positioned somewhere at the left of the node with 22. But it is greater than the node with 10. Therefore, 16 is going to be to the right of the node with 10.

This trend continues until all data values have been rightly positioned.

PS: A binary tree is a data structure in which each node cannot have more than two nodes directly attached to it.

Suppose that we want to multiply 500 matrices and we use the optimal parenthesization computed by the MATRIX-CHAIN-ORDER function discussed in class. After finding the optimal parenthesization, how many pairs of round brackets ( ) are printed by the procedure PRINT-OPTIMAL-PARENS(s, 1, 500)?
a. 249
b. 501
c. 251
d. 250
e. 499
f. 500

Answers

Answer:

síganme en las claves de ustedes pronto. Seré un buen día. He seguido un poco sobre el Is. He seguido un poco sobre el Is. He seguido un poco sobre el.

is (c)251? correct since i'm not really sure

Consider these functions:_________.
def f(x) :
return g(x) + math.sqrt(h(x))
def g(x):
return 4 h(x)
def h(x):
return x x + k(x)-1
def k(x):
return 2 (x + 1)
Without actually compiling and running a program, determine the results of the following function calls.
a. x1 = f(2)
b. x2 = g(h(2)
c. x3 = k(g(2) + h(2))
d. x4 - f(0) + f(l) + f(2)
e. x5 - f{-l) + g(-l) + h(-1) + k(-l)

Answers

Answer:

x1 = 39

x2 = 400

x3 = 92

x4 = 62

x5 = 0

Explanation:

a. x1 = f(2)

This statement calls the f() function passing 2 to the function. The f(x) function takes a number x as parameter and returns the following:

g(x) + math.sqrt(h(x))

This again calls function g() and h()  

The above statement calls g() passing x i.e. 2 to the function g(x) and calls function h() passing x i.e. 2 to h() and the result is computed by adding the value returned by g() to the square root of the value returned by the h() method.

The g(x) function takes a number x as parameter and returns the following:

return 4*h(x)

The above statement calls function h() by passing value 2 to h() and the result is computed by multiplying 4 with the value returned by h().

The h(x) function takes a number x as parameter and returns the following:

return x*x + k(x)-1

The above statement calls function k() by passing value 2 to k() and the result is computed by subtracting 1 from the value returned by k() and adding the result of x*x (2*2) to this.

The k(x) function takes a number x as parameter and returns the following:

return 2 * (x + 1)

As the value of x=2 So

2*(2+1) = 2*(3) = 6

So the value returned by k(x) is 6

Now lets go back to the function h(x)

return x*x + k(x)-1

x = 2

k(x) = 6

So

x*x + k(x)-1 = 2*2 + (6-1) = 4 + 5 = 9

Now lets go back to the function g(x)

return 4*h(x)

As x = 2

h(x) = 9

So

4*h(x)  = 4*9 = 36

Now lets go back to function f(x)

return g(x) + math.sqrt(h(x))

As x=2

g(x) = 36

h(x) = 9

g(x) + math.sqrt(h(x))  = 36 + math.sqrt(9)

                                  = 36 + 3 = 39

Hence

x1 = 39b. x2 = g(h(2) )

The above statement means that first the function g() calls function h() and function h() is passed a value i.e 2.

As x=2

The function k() returns:

2 * (x + 1)   = 2 * (2 + 1) = 6

The function h() returns:

x*x + k(x)-1 = 2*2 + (6-1) = 4 + 5 = 9

Now The function g() returns:

4 * h(x)  = 4 * h(9)

This method again calls h() and function h() calls k(). The function k() returns:

2 * (x + 1)   = 2 * (9 + 1) = 20

Now The function h() returns:

x*x + k(x)-1 = 9*9 + (20-1) = 81 + 19 = 100

h(9) = 100

Now The function g() returns:

4 * h(x)  = 4 * h(9) = 4 * 100 = 400

Hence

x2 = 400c. x3 = k(g(2) + h(2))

g() returns:

return 4 h(x)

h() returns:

return x*x + k(x)-1

k(2) returns:

return 2 (x + 1)

          = 2 ( 3 ) = 6

Now going back to h(2)

x * x + k(x)-1  = 2*2 + 6 - 1 = 9

Now going back to g(2)

4 h(x)  = 4 * 9 = 36

So k(g(2) + h(2)) becomes:

   k(9 + 36 )

    k(45)

Now going to k():

return 2 (x + 1)

2 (x + 1)   = 2(45 + 1)

             = 2(46)

             = 92

So k(g(2) + h(2)) = 92

Hence

x3 = 92d. x4 = f(0) + f(1) + f(2)

Compute f(0)

f() returns:

return g(0) + math.sqrt(h(0))

f() calls g() and h()

g() returns:

return 4 * h(0)

g() calls h()

h() returns

return 0*0 + k(0)-1

h() calls k()

k() returns:

return 2 * (0 + 1)

2 * (0 + 1)  = 2

Going back to caller function h()

Compute h(0)

0*0 + k(0)-1  = 2 - 1 = 1

Going back to caller function g()

Compute g(0)

4 * h(0)  = 4 * 1 = 4

Going back to caller function f()

compute f(0)

g(0) + math.sqrt(h(0))  = 4 + 1 = 5

f(0) = 5

Compute f(1)

f() returns:

return g(1) + math.sqrt(h(1))

f() calls g() and h()

g() returns:

return 4 * h(1)

g() calls h()

h() returns

return 1*1 + k(1)-1

h() calls k()

k() returns:

return 2 * (1 + 1)

2 * (1 + 1)  = 4

Going back to caller function h()

Compute h(0)

1*1 + k(1)-1  = 1 + 4 - 1 = 4

Going back to caller function g()

Compute g(1)

4 * h(1)  = 4 * 4 = 16

Going back to caller function f()

compute f(1)

g(1) + math.sqrt(h(1))  = 16 + 2 = 18

f(1) = 18

Compute f(2)

f() returns:

return g(2) + math.sqrt(h(2))

f() calls g() and h()

g() returns:

return 4 * h(2)

g() calls h()

h() returns

return 1*1 + k(2)-1

h() calls k()

k() returns:

return 2 * (2+1)

2 * (3)  = 6

Going back to caller function h()

Compute h(2)

2*2 + k(2)-1  = 4 + 6 - 1 = 9

Going back to caller function g()

Compute g(2)

4 * h(2)  = 4 * 9 = 36

Going back to caller function f()

compute f(2)

g(2) + math.sqrt(h(2))  = 36 +3 = 39

f(1) = 13.7

Now

x4 = f(0) + f(l) + f(2)

    = 5 + 18 + 39

    = 62

Hence  

x4 = 62e. x5 = f(-1) + g(-1) + h(-1) + k(-1)

Compute f(-1)

f() returns:

return g(-1) + math.sqrt(h(-1))

f() calls g() and h()

g() returns:

return 4 * h(-1)

g() calls h()

h() returns

return 1*1 + k(-1)-1

h() calls k()

k() returns:

return 2 * (-1+1)

2 * (0)  = 0

Going back to caller function h()

Compute h(-1)

-1*-1 + k(-1)-1  = 1 + 0 - 1 = 0

Going back to caller function g()

Compute g(-1)

4 * h(-1)  = 4 * 0 = 0

Going back to caller function f()

compute f(-1)

g(-1) + math.sqrt(h(-1))  = 0

f(-1) = 0

Compute g(-1)

g() returns:

return 4 * h(-1)

g() calls h()

h() returns

return 1*1 + k(-1)-1

h() calls k()

k() returns:

return 2 * (-1+1)

2 * (0)  = 0

Going back to caller function h()

Compute h(-1)

-1*-1 + k(-1)-1  = 1 + 0 - 1 = 0

Going back to caller function g()

Compute g(-1)

4 * h(-1)  = 4 * 0 = 0

g(-1) = 0

Compute h(-1)

h() returns

return 1*1 + k(-1)-1

h() calls k()

k() returns:

return 2 * (-1+1)

2 * (0)  = 0

Going back to caller function h()

Compute h(-1)

-1*-1 + k(-1)-1  = 1 + 0 - 1 = 0

h(-1) = 0

Compute k(-1)

k() returns:

return 2 (x + 1)

k(-1) = 2 ( -1 + 1 ) = 2 ( 0 ) = 0

k(-1) = 0

x5 = f(-1) + g(-1) + h(-1) + k(-1)

    = 0  + 0 + 0 + 0

    = 0

Hence

x5 = 0

Passing structured query language commands to a web application and getting the website to execute it is called SQL script:______.
A) Injection.
B) Processing.
C) Attacking.
D) Execution.

Answers

Answer:

(A) Injection

Explanation:

SQL injection is one of the most common web attacks used by attackers to steal data or compromise a web application (especially the database) by inserting or "injecting" SQL queries or commands through the input data from the web application.

In web applications, form inputs are used to make requests to the database either for validation or submission of data by executing queries in the database. If these queries are interfered with by passing query like commands into the form input fields rather than some regular alphanumeric characters, then we have an SQL injection.

When this happens;

i. the attackers can modify an SQL query to return additional results from the database

ii. the attackers can change a query to interfere with the application's regular logic flow.

iii. the attackers can extract sensitive information about the database such as its version and structure.

Write a Python program that asks the user for a positive, odd value. Once the value is validated determine if the number is Prime (i.e., divisible only by itself and 1.)

Answers

Answer:

val = int(input("Enter a positive odd value "))

flag = True # let the number entered is alreay prime

if(val > 2 and val%2 == 1):  # prime numbers start from 2

   half = int(val/2);

   for div in range(2,half):  # dividing the number from 2 to half of its number

       if(val % div == 0): # if completely divisible

           print("Not prime")

           flag = False   # Changing the status of prime number as false

           break

   if(flag == True):

       print(val, "is a prime number")

else:

   print("Invalid input, Please Enter a valid positive odd number")

Explanation:

Steps:

1. Let us take input from the user using input() method.

2.  Initially, let the number is prime.

3. If the number is negative or even, the go to else part and ask the user for a valid input and terminate the program by giving a message to user.

(We actually check for values greater than 2 because 1 is not considered as  a prime number)

4. If the number is positive and odd, then we keep on dividing the number from 2 to half of its number.

(We actually check for values greater than 2 because 1 is not considered as  a prime number)

5. If the number is divisible, we change the status to False and break the loop.

6. If the flag is still True, we print that it is a Prime number else we print that it is not a prime number.

Please refer to the comments section as well and the attached image for proper indentation of the program.

What is a real-life example of a Microsoft Access Query?

Answers

Explanation:

Microsoft Access is an information management tool that helps you store information for reference, reporting, and analysis. Microsoft Access helps you analyze large amounts of information, and manage related data more efficiently than Microsoft Excel or other spreadsheet applications.

A real-life example of a Microsoft Access Query is a table that stores the names of new customers at a supermarket.

What is Microsoft Access?

Microsoft Access is a database management software application designed and developed by Microsoft Inc., in order to avail its end users an ability to create, store and add data to a relational database.

In Microsoft Access, the options that are available on the File tab include the following:

Opening a database.

Selecting a template.

Creating a new database.

In conclusion, a database is an element in Microsoft Access which is an ideal data source and a query would always obtain, generate, or pick information from it.

Read more on Microsoft Access here: brainly.com/question/11933613

#SPJ2

nside of your organization that checks how often client machines access it. If a client machine hasn't accessed the server in three months, the server won't allow the client machine to access its resources anymore. What can you set to make sure that your client machines and the server times are in sync

Answers

Complete Question:

Let's say that you handle the IT systems administration for your company. There's a server inside of your organization that checks how often client machines access it. If a client machine hasn't accessed the server in three months, the server won't allow the client machine to access its resources anymore. What can you set to make sure that your client machines and the server times are in sync?

Answer:

Network Time Protocol (NTP).

Explanation:

As the IT systems administrator, you can set the network time protocol (NTP) to make sure that your client machines and the server times are in synchronization.

A network time protocol (NTP) can be defined as an internet standard protocol which is used by an IT system administrator to synchronize a computer's clock to a particular time reference over packet switched or local area network (LAN) and variable-latency data networks. NTP was developed at the University of Delaware by Professor David L. Mills.

Basically, the network time protocol uses the coordinated universal time (UTC) and a client-server model to measure the total round-trip delay for a computer process.

Using a variable length array, write a C program that asks the user to enter test scores.Then, the program should calculate the average, determine the lowest test score, determine the letter grade, and display all three.

Answers

Answer:

Here is the C program :

#include<stdio.h>  // to use input output functions

   int main(){  //start of main() function body

   int n;  //to store the number of tests taken

   int test_scores[n], i;  //a variable length array test_score

   float sum=0,average;  //to store the sum and average of test scores

   int lowest;   //to store the lowest test score

   printf("Enter the number of tests taken :");//prompts user to enter number of test scores

   scanf("%d",&n); /  / reads the value of n from user

   printf("Enter test scores: ");  //prompts user to enter test scores

for(i=0; i<n; i++)  {  

 scanf("%d",&test_scores[i]);  //read the values of input test scores

 sum = sum + test_scores[i];   } //calculates the sum of the test scores by adding the values of test scores

        average=sum/n;  // compute the average by dividing sum of all test scores with the total number of test scores

               printf("Average is %.2f",average);  //displays the average

    printf("\nGrade is ");  // prints Grade is

    if (average >= 90) {  //if value of average is greater than or equal to 90

       printf("A");     }  //print the grade letter A

else if(average >= 80 && average < 90)  { //if value of average is greater than or equal to 80 and less than 90

 printf("B");  }   //print the grade letter B

else if(average>60 && average<80){ //if value of average is between 60 and 80

 printf("C");  }  //print the grade letter C

else if(average>40 && average<=60) {  //if value of average is greater than 40 and less than or equals to 60

 printf("D");  }  //print the grade letter D

else  {  //if the value of average is below 40

 printf("F");  }   //print the grade letter F

   lowest = test_scores[0];     //lowest points to the 1st element of test scores means the first input test score

   for (int j = 1; j < n;j++)     {  //loop iterates through the scores

       if (test_scores[j] < lowest)   {  // if the element at j-th index position of test_scores array is less than the element stored in the lowest variable

          lowest = test_scores[j];     }     } //then assign that element value of test_score to the lowest

     printf("\nLowest test score is:  %d.\n", lowest); } //displays the lowest test score

Explanation:

The program is well explained in the comments mentioned with each statement of the code.

The program prompts the user to enter the number of test scores as they are not already specified in the array because array test_scores is a variable length array which means its length is not fixed. The program then prompts the user to enter the test scores. The program then adds all the test scores and store the result in sum variable. Then it computes the average by dividing the value in sum variable to the number of test scores n. Then in order to determine the letter Grade the average value is used. The if else conditions are used to specify conditions in order to determine the Grade. Next the lowest score is determined by setting the value of lowest variable to the first element of the test_scores array. Then using for loop, the index variable j moves to each array element i.e. score and determines if the the value of element is less than that stored in the lowest variable. If the value positioned at j-th index of test_scores is less than that of lowest than this value is assigned to lowest. At last the lowest holds the minimum of the test scores.

When you sustain program implementation by staying true to the original design, it is termed A. Goals and objectives B. Program fidelity C. Program evaluation D. Program management

Answers

Answer:

Program fidelity

Explanation:

Consider the following code segment. It should display a message only if the cost is between 50 and 75 dollars. The message should also be displayed if the cost is exactly 50 dollars or exactly 75 dollars. if _________________ : print("The cost is in the desired range") What condition should be placed in the blank to achieve the desired behavior

Answers

Answer:

In C++ it can be written as:

if(cost>=50&&cost<=75)

   { cout<<"The cost is in the desired range";}

In Python:

if(cost <= 75 and cost>= 50):

   print("The cost is in the desired range")

Explanation:

cost>50&&cost<75 covers the requirement that cost should be between 50 and 75 dollars

But the whole statement cost>=50&&cost<=75 covers the requirement that cost should be between 50 and 75 dollars and message should also be displayed if the cost is exactly 50 dollars or exactly 75 dollars. For example if the value of cost=50 then this message The cost is in the desired range is displayed.

In the above program && in C++, and in Python is used which is a logical operator which means that both the conditions cost <= 75 and cost>= 50 should be true for the if condition to evaluate to true. For example if cost=35 then this message is not printed because both the conditions are false i.e. 35 is neither less than or equal to 75 nor greater than or equal to 50.

The code below takes the list of country, country, and searches to see if it is in the dictionary gold which shows some countries who won gold during the Olympics. However, this code currently does not work. Correctly add try/except clause in the code so that it will correctly populate the list, country_gold, with either the number of golds won or the string "Did not get gold".
1
​2 gold = {"US":46, "Fiji":1, "Great Britain":27, "Cuba":5, "Thailand":2, "China":26, "France":10}
3 country = ["Fiji", "Chile", "Mexico", "France", "Norway", "US"]
4 country_gold = []
5
​6 for x in country:
7 country_gold.append(gold[x])
8 country_gold.append("Did not get gold")

Answers

Answer:

Modify your program by replacing

for x in country:

       country_gold.append(gold[x])

       country_gold.append("Did not get gold")

with

for x in country:

       try:

               country_gold.append(gold[x])

       except:

               country_gold.append("Did not get gold")

Explanation:

The addition of try/except clause in the program is to let the program manage error;

In this case, the program checks for a country in the list country; This is implemented using the following line

for x in country:

If the country exists, the statement in the try block is executed

try:

 country_gold.append(gold[x])  ->This appends the country name to the country_gold list

Otherwise, the statement in the except clause is executed

except:

 country_gold.append("Did not get gold")  -> This appends "Did not get gold" to the country_gold list

To confirm what you've done, you may add the following line of code at the end of the program: print(country_gold)

Other Questions
Alexandria ate at most two hundred fifty calories more than twice the number of calories her infant sister ate. Alexandria ate eighteen hundred calories. If i represents the number of calories eaten by the infant, which inequality represents the situation? A. 1,800 less-than-or-equal-to 250 + 2 i B. 1,800 less-than 250 + 2 i C. 1,800 + 250 greater-than 2 i D. 1,800 + 250 greater-than-or-equal-to 2 i Which of the following is one of the three variables proposed by a basic OB model which refers to actions that individuals, groups, and organizations engage in as a result of inputs?a. Processesb. Scrutinizationc. Planningd. Associatione. Evaluation Use the Cross Products Property to solve the proportion5/n =16/32 Select the correct answer.Pam is planning to use a lathe to finish her woodworking project. What kind of dress should she avoid wearing?A. loose dressB. woolen dressC. cotton dressD. synthetic dress A combination lock has 6 different numbers. If each number can only be used ONCE, how many different combinations are possible? If Tamarisk, Inc. realizes a loss of $9400 on a cash sale of office equipment having a book value of $93600, the total amount reported in the cash flows from investing activities section of the statement of cash flows is What is the vertex of the graph of the function f(x) = x2+8x-2? Solve on the interval [0,2pi)4 CSC x + 1 = -3 A plane traveled 5525 miles with the wind in 8.5 hours and 4505 miles against the wind in the same amount of time. Find the speed of the plane in still air and the speed of the wind. The speed of the plane in still air is ____(hours.miles.mph) (Simplify your answer.) Marcy listed her property with Jennings Homes in March. The market was slow, and Marcy's property isn't in great conditionthough she's sure she can get top dollar for it because of its location. Her agent encouraged her to either reduce the price or fix the property up, but she refused. Both Marcy and her agent are frustrated. What's the best option for both of them? simplify 8a-5b-(6a-9b) Which of the following is most likely the next step in the series? Complete the tag question.Laura: Eva es muy simptica, __________?Marc: S, ella es muy simptica. yeast infections may affect as many as 75 percent of woman What is the difference between a parent isotope and a daughter isotope? Please help asap.A pizza is cut into six unequal slices (each cut starts at the center). The largest slice measures $90$ degrees If Larry eats the slices in order from the largest to the smallest, then the number of degrees spanned by a slice decreases at a constant rate. (So the second slice is smaller than the first by a certain number of degrees, then the third slice is smaller than the second slice by that same number of degrees, and so on.) What is the degree measure of the fifth slice Larry eats? How many different isosceles triangles have integer side lengths and perimeter 23? Between lowering taxes and beginningthe War on Terror, what happenedwhile President George W. Bush wasin office? Why was there a need for an official languages law In this speech, Truman is:telling Americans why they should re-elect him.explaining the failures of the Democratic party.praising the efforts of the Republican party.None of these choices are correc