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.

Answers

Answer 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.

Write A Function Named TwoWordsV2 That Has The Same Specification As Problem 1, But Implement It Using
Answer 2

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


Related Questions

Say our confusion matrix is as follows, calculate precision, recall, and accuracy. Interpret the results for the positive class. Show and explain work.
[25 4
3 25]

Answers

It can also be calculated as 1 – specificity. False positive rate is calculated as the number of incorrect positive predictions (FP) divided by the total number of negatives (N

Using SQL
Use the blog database
Write a SQL RIGHT OUTER JOIN statement that joins the user_id column from the blog.posts table, the name column of the blog.users table and the body column of the blog.posts table together

Answers

Answer:

Following are the code to this question:

/*using the select statement, that selects column name from the table blog.posts */  

SELECT blog.posts.user_id, blog.posts.body, users.name/*column name user_id, body, name*/  

FROM blog.posts/* use table name blog.posts*/

RIGHT OUTER JOIN users ON blog.posts.user_id = users.id;/*use right join that connect table through user_id*/

Explanation:

In the structured query language, RIGHT JOIN  is used to recovers from both the right side of the table both numbers, although the left table has no sets. It also ensures that even if the 0 (null) documents are linked inside this left table, its entry will always return the outcome row, but still, the number of columns from its left table will be NULL.

In the above-given right join code, the select statements used that selects the column names "user_id, body, and the name" from the table "blog. posts" and use the right join syntax to connect the table through the id.    

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.

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:

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.  

Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context switching overhead is 0.1 millisecond and that all processes are long-running tasks. What is the CPU utilization for a round-robin scheduler when:

Answers

Answer:

10 minutes

Explanation:

Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of the base class' printAll() method. Name: Fluffy, Age: 5, ID: 4444

Answers

Answer and Explanation:

public class petData

{

private int ageYears;

private String fullName;

private int IdNumber;

public void setName (String givenName)

{

fullName = givenName;

return;

}

public void setAge (int numYears)

{

ageYears = numYears;

return;

}

public void setID (int numID)

{

IdNumber = numID;

return;

}

public void printAll ()

{

System.out.print ("Name: " + fullName);

System.out.print (", Age: " + ageYears);

return;

}

}

From the above, we have defined a class petData, with methods setName, setAge, printAll. These methods all make use of the string variable fullName and integer variable ageYears. From the above, setName method sets fullName variable to name given to its string parameter givenName while setAge method does the same with the ageYears variable in initializing it. This is also done by the ID method. These variables are then used by printAll method in printing out the Name and age of the object which would be created with the petData class

E. g: petData dog= new petData();

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.

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

#The Fibonacci sequence is a number sequence where each #number is the sum of the previous two numbers. The first #two numbers are defined as 0 and 1, so the third number is #1 (0 + 1 = 1), the fourth number is 2 (1 + 1 = 2), the #fifth number is 3 (1 + 2 = 3), the sixth number is 5 #(2 + 3 = 5), and so on.
#
#Below we've started a class called FibSeq. At any time, #FibSeq holds two values from the Fibonacci sequence: #back1 and back2.
#
#Create a new method inside FibSeq called next_number. The #next_number method should:
#
# - Calculate and return the next number in the sequence, # based on the previous 2. # - Update back2 with the former value of back1, and update # back1 with the new next item in the sequence.
#
#This means that consecutive calls to next_number should #yield each consecutive number from the Fibonacci sequence. #Calling next_number 5 times would print 1, 2, 3, 5, and 8.
class FibSeq:
def __init__(self):
self.back1 = 1
self.back2 = 0
def next_number(self):
self.back1=self.back1+self.back2 # updated the back1 value to the next number in the series first
self.back2=self.back1-self.back2 #updated the back2 value with previous back1 value
yield (self.back1) # yielded the next number in the series since it is updated as back1 so yielded back1
f = FibSeq()
for i in range(5): # here i have iterated the series only 5 times u can change it as you like
s=f.next_number()
print(next(s))# here next is an iterator function for the yield generator.
#The code below will test your method. It's not used for
#grading, so feel free to change it. As written, it should
#print 1, 2, 3, 5, and 8.
newFib = FibSeq()
print(newFib.next_number())
print(newFib.next_number())
print(newFib.next_number())
print(newFib.next_number())
print(newFib.next_number())

Answers

Answer:

Here is the next_number method:

def next_number(self): #method to return next number in the sequence

    temporary = self.back1 + self.back2 # adds previous number to next number and stores the result in a temporary variable

    self.back2 = self.back1 #Updates back2 with the former value of back1,

    self.back1 = temporary #update back1 with the new next item in the sequence.

    return temporary #

Explanation:

I will explain the working of the above method.

back1 = 1

back2 = 0

At first call to next_number()  method:

temporary = back1 + back2

                 = 1 + 0

temporary = 1

self.back2 = self.back1

self.back2 = 1

self.back1 = temporary

self.back1 = 1

return temporary

This return statement returns the value stored in temporary variable i.e. 1

Output: 1

back1 = 1

back2 = 1

At second call to next_number()  method:

temporary = back1 + back2

                 = 1 + 1

temporary = 2

self.back2 = self.back1

self.back2 = 1

self.back1 = temporary

self.back1 = 2

return temporary

This return statement returns the value stored in temporary variable i.e. 2

output: 2

back1 = 2

back2 = 1

At second call to next_number()  method:

temporary = back1 + back2

                 = 2 + 1

temporary = 3

self.back2 = self.back1

self.back2 = 2

self.back1 = temporary

self.back1 = 3

return temporary

This return statement returns the value stored in temporary variable i.e. 3

Output: 3

back1 = 3

back2 = 2

At second call to next_number()  method:

temporary = back1 + back2

                 = 3 + 2

temporary = 5

self.back2 = self.back1

self.back2 = 3

self.back1 = temporary

self.back1 = 5

return temporary

This return statement returns the value stored in temporary variable i.e. 5

Output: 5

back1 = 5

back2 = 3

At second call to next_number()  method:

temporary = back1 + back2

                 = 5 + 3

temporary = 8

self.back2 = self.back1

self.back2 = 5

self.back1 = temporary

self.back1 = 8

return temporary

This return statement returns the value stored in temporary variable i.e. 8

Output: 8

Calling next_number 5 times would print 1, 2, 3, 5, and 8.

The complete program along with its output is attached.

17. Write a query to get the Order ID, the name of the company that placed the order, and the first and last name of the associated employee. g

Answers

Answer:

Required code present in image attached

Explanation:

At first, the subquery (i.e., the inner query) will execute one time before executing the main query (i.e., outer query).  This sequence is important since the result from the subquery is being utilized for when the main query executes to produced the desired outcome. The final result will be obtained after the last line of code executes.

A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the client, the service sold (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a program that reads such a file and displays the total amount for each service category. Display an error if the file does not exist or the format is incorrect.

Answers

Answer:

Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?

Explanation:

Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?

A sample containing 4.30 g of O2 gas has an initial volume of 13.0 L. What is the final volume, in liters, when each of the following changes occurs in the quantity of the gas at constant pressure and temperature.

A sample of 200 g of O, is removed from the 4.30 g of O, in the container.​

Answers

Answer:

Total amount of O₂ occupy volume = 76.50 L

2 .30 gm O₂ occupy volume = 7.48 L

Explanation:

We konw that,

Molar mass of O₂ = 31.9988 gm / mol

1 mole of O₂ = 31.9988 gm

Sample of oxygen = 0.600 mole

Computation:

0.600 mole = 31.9988 × 0.600

0.600 mole = 19.199 gm

Total amount of O₂ = 4.30 + 19.199

Total amount of O₂ = 23.499 gm

Total amount of O₂ occupy volume = 14 × 23.499/4.30

Total amount of O₂ occupy volume = 76.50 L

Total gm of O₂ = 4.30 - 2.00= 4.30 gm

2 .30 gm O₂ occupy volume = 14 × 2.30/4.30

2 .30 gm O₂ occupy volume = 7.48 L

A use case description is the best place to start for the design of the forms for a user interface.​ True False

Answers

Answer:

false

Explanation:

Why do you think it is necessary to set the sequence in which the system initializes video cards so that the primary display is initialized first

Answers

Answer:

Because if you don't do it BIOS doesn't support it. ... In troubleshooting a boot problem what would be the point of disabling the quick boot feature in BIOS setup

Explanation:

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.

An Open Authorization (OAuth) access token would have a _____ that tells what the third party app has access to

Answers

Answer:

scope

Explanation:

An Open Authorization refers to a method  that helps to share data using third party services without giving your credentials and there is a mechanism in an Open Authorization that allows to limit the access that the third party app has to an account that is called scope. Because of that, the answer is that an Open Authorization (OAuth) access token would have a scope that tells what the third party app has access to because it is what limits the access the app has to an account and it shows the access given in a consent screen.

Suppose that a server sends four packets of audio data, in 15 seconds each. The first is sent by the server exactly at noon (12:00:00), while each of the three successive packets is sent immediately after the completion of its predecessor. The client, on the other hand, receives the four packets beginning at 12:00:03, 12:00:20, 12:00:41, 12:00:59 respectively. What is the smallest delayed wait time (buffer) in seconds that would ensure the client had seamless playback (i.e. each packet plays immediately after the previous one ends)?

Answers

Answer:

15

Explanation:

for seamless playback each packet should be played before their predecessor so

4th packet will start at 12:01:03

3rd packet will start at 12:00:48

2nd packet will start at 12:00:33

1st packet will start at 12:00:18

as first packet arrives at 12:00:03 so wait time is 15 seconds for seamless playback

state five uses of building​

Answers

Housing, warmth, shelter, to flex on others and pleasure

Hope this helped, but I doubt it(╹◡╹)
Answer

1) Housing

2) Power generation (factories and nuclear reactors)

3) Agriculture (greenhouse)

4) Research (Infectious Diseases Research, isolating different viruses to study them in laboratory conditions)

5) Entertainment and leisure (cinemas, shopping centres)

6) Law and governmental buildings

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.

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.

g Write a program that asks for the weight of a package and the distance it is to be shipped. This information should be passed to a calculateCharge function that computes and returns the shipping charge to be displayed . The main function should loop to handle multiple packages until a weight of 0 is entered.

Answers

Answer:

I am writing a C++ program:

#include <iostream>  //to use input output functions

#include<iomanip>  // to format the output

using namespace std;   // to identify objects like cin cout

void calculateCharge(double weight, double distance);   // function prototype

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

  double w = 0.0, t = 0.0;  // w variable is for weight and t is for total

   unsigned int d = 0;   // d variable is to hold the value of distance

   calculateCharge(w, d); }  //calls calculateCharge method by passing weight and distance values to this method

void calculateCharge(double weight, double distance){  //method that takes weight and distance as parameters and compute the shipping charge

   double charge = 0.0;  //to store the value of shipping charges

   do {  // do while loop to handle multiple packages until a weight of 0 is entered

       cout << "Enter weight: " << endl;  //prompts user to enter weight

       cin >> weight;  //reads the input weight value

       if (weight == 0){  // if the value of weight is equal to 0

           break; }  // the loop breaks if value of weight is 0

       cout << "Enter distance: " << endl;  // if value of weight is not zero then the program precedes by prompting user to enter the value of distance

       cin >> distance;  //reads the input distance value

       cout << fixed << setprecision(2) << endl;  //set the precision to 2 means the sets the number of digits of an output to 2 decimal places

       if(weight <= 2)  //if the value of weight is less than or equals to 2

charge = (distance/500) * 3.10;  //compute the charge by this formula

else if(weight > 2 && weight <= 6)  //if weight is over 2 kg but not more than 6 kg

charge = (distance/500) * 4.20;  //charge is computed by multiplying value of distance to that of weight and if distance is greater than 500 then it is divided by 500 first

else if(weight > 6 && weight <= 10)  // if weight is over 6 kg but not more than 10 kg

charge = (distance/500) * 5.30;  //compute shipping charges by this formula

else  //if weight is over 10 kg

charge = (distance/500) * 6.40;   // compute shipping charge by multiplying value of distance to that of 6.40 weight value and if distance is greater than 500 then distance is divided by 500 first

cout << "Shipping charges: $" << charge << "\n";   //display the computed shipping charge

   } while (weight != 0);  //the loop continues to execute until weight 0 is entered

}              

Explanation:

The program is explained in the comments mentioned above. The program has a main() function that declares variable for weight, distance and total and then calls calculateCharge() method passing weight and dsitance in order to compute and return the shipping charge.

In calculateCharge() the user is prompted to enter the values for weight and distance. Then the based on the value of weight , the shipping charge is computed. Shipping charge is computed by multiplying the weight with distance. The distance is assumed to be 500 but if the distance entered by user exceeds 500 then the distance value is divided by 500 and then multiplied by the specified weight (according to if or else if conditions) in order to compute shipping charge. The program has a do while loop that keeps taking input from user until the user enters 0 as the value of weight.

The screenshot of the program and its output is attached.

C++ Fibonacci
Complete ComputeFibonacci() to return FN, where F0 is 0, F1 is 1, F2 is 1, F3 is 2, F4 is 3, and continuing: FN is FN-1 + FN-2. Hint: Base cases are N == 0 and N == 1.
#include
using namespace std;
int ComputeFibonacci(int N) {
cout << "FIXME: Complete this function." << endl;
cout << "Currently just returns 0." << endl;
return 0;
}
int main() {
int N = 4; // F_N, starts at 0
cout << "F_" << N << " is "
<< ComputeFibonacci(N) << endl;
return 0;
}

Answers

Answer:

int ComputeFibonacci(int N) {

   if(N == 0)

       return 0;

   else if (N == 1)

       return 1;

   else

       return ComputeFibonacci(N-1) + ComputeFibonacci(N-2);

}

Explanation:

Inside the function ComputeFibonacci that takes one parameter, N, check the base cases first. If N is eqaul to 0, return 0. If N is eqaul to 1, return 1. Otherwise, call the ComputeFibonacci function with parameter N-1 and N-2 and sum these and return the result.

For example,

If N = 4 as in the main part:

ComputeFibonacci(4) → ComputeFibonacci(3) + ComputeFibonacci(2) = 2 + 1 = 3

ComputeFibonacci(3) → ComputeFibonacci(2) + ComputeFibonacci(1) = 1 + 1 = 2

ComputeFibonacci(2) → ComputeFibonacci(1) + ComputeFibonacci(0) = 1 + 0  = 1

*Note that you need to insert values from the bottom. Insert the values for ComputeFibonacci(1) and  ComputeFibonacci(0) to find ComputeFibonacci(2) and repeat the process.

Implement function easyCrypto() that takes as input a string and prints its encryption
defined as follows: Every character at an odd position i in the alphabet will be
encrypted with the character at position i+1, and every character at an even position i
will be encrypted with the character at position i 1. In other words, ‘a’ is encrypted with
‘b’, ‘b’ with ‘a’, ‘c’ with ‘d’, ‘d’ with ‘c’, and so on. Lowercase characters should remain
lowercase, and uppercase characters should remain uppercase.
>>> easyCrypto('abc')
bad
>>> easyCrypto('Z00')
YPP

Answers

Answer:

The program written in python is as follows;

import string

def easyCrypto(inputstring):

      for i in range(len(inputstring)):

             try:

                    ind = string.ascii_lowercase.index(inputstring[i])

                    pos = ind+1

                    if pos%2 == 0:

                           print(string.ascii_lowercase[ind-1],end="")

                    else:

                           print(string.ascii_lowercase[ind+1],end="")

             except:

                    ind = string.ascii_uppercase.index(inputstring[i])

                    pos = ind+1

                    if pos%2 == 0:

                           print(string.ascii_uppercase[ind-1],end="")

                    else:

                           print(string.ascii_uppercase[ind+1],end="")

anystring = input("Enter a string: ")

easyCrypto(anystring)

Explanation:

The first line imports the string module into the program

import string

The functipn easyCrypto() starts here

def easyCrypto(inputstring):

This line iterates through each character in the input string

      for i in range(len(inputstring)):

The try except handles the error in the program

             try:

This line gets the index of the current character (lower case)

                    ind = string.ascii_lowercase.index(inputstring[i])

This line adds 1 to the index

                    pos = ind+1

This line checks if the character is at even position

                    if pos%2 == 0:

If yes, it returns the alphabet before it

                           print(string.ascii_lowercase[ind-1],end="")

                    else:

It returns the alphabet after it, if otherwise

                           print(string.ascii_lowercase[ind+1],end="")

The except block does the same thing as the try block, but it handles uppercase letters

             except:

                    ind = string.ascii_uppercase.index(inputstring[i])

                    pos = ind+1

                    if pos%2 == 0:

                           print(string.ascii_uppercase[ind-1],end="")

                    else:

                           print(string.ascii_uppercase[ind+1],end="")

The main starts here

This line prompts user for input

anystring = input("Enter a string: ")

This line calls the easyCrypto() function

easyCrypto(anystring)

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))

Kaiden would like to find the list of physical disk drives that are connected to a Linux system. Which directory contains a subdirectory for each drive

Answers

Answer:

The answer is "\root"

Explanation:

The root directory is the part of the Linux OS directory, which includes most other system files and folders but is specified by a forward slash (/). These directories are the hierarchy, which is used to organize files and folders on a device in a standardized protocol framework.  This root is also known as the top directory because it .supplied by the os and also is designated especially, that's why it is simply called root.

Early in the history of technology, the development of tools and machines was based on _____ versus scientific knowledge as is done today. * 5 points technology and mathematics principles the engineering design process technical know-how positive and negative effects of using technology

Answers

Answer:

Early in the history of technology, the development of tools and machines was based on technical know-how versus scientific knowledge as is done today.

Explanation:

In the era prior to technological development, men had a basic and at times rudimentary manufacturing development, based on artisan processes that developed their tools and machinery by hand, without any type of automation or mass production rules.

Thus, each part or tool was manufactured in a unique way, which required a broad mastery of the production process by the manufacturer. This is how the first professions began to emerge, such as blacksmiths for example, who mastered the technique of manufacturing different implements and carried them out without any scientific knowledge.

Modularize the program by adding the following 4 functions. None of them have any parameters. void displayMenu() void findSquareArea() void findCircleArea() void findTriangleArea() To do that you will need to carry out the following steps: Write prototypes for the four functions and place them above main. Write function definitions (consisting of a function header and initially empty body) for the four functions and place them below main. Move the appropriate code out of main and into the body of each function. Move variable definitions in main for variables no longer in main to whatever functions now use those variables. They will be local variables in those functions. For example, findSquareArea will need to define the side variable and findCircleArea will need to define the radius variable. All of the functions that compute areas will now need to define a variable named area. Move the definition for the named constant PI out of main and place it above the main function. In main, replace each block of removed code with a function call to the function now containing that block of code.

Answers

Answer:

It is a C++ program  :

#include <iostream>  // to use input output functions

using namespace std;  //to identify objects like cin cout

//following are the prototypes for the four functions placed above main

void displayMenu();  

void findSquareArea();  

void findCircleArea();

void findTriangleArea();

//definition for constant PI out of main

const float PI = 3.14159;  

int main(){  //start of main function

displayMenu(); //calls displayMenu() method

}

  void displayMenu(){  // to make user selection and calls relevant function to compute area according to the choice of user

int selection=0;  //to choose from 4 options

cout<<"Program to calculate areas of objects:\n" ;  //displays this message at start

do  {  //this loop asks user to enter a choice and this continues to execute and calculate depending on users choice until user enters 4 to exit

cout<<"\n1.Square \n2.Circle \n3.Right Triangle \n4.Quit";

cout<<"\nEnter your choice:";  //prompts user to enter choice

cin>>selection;  //reads the input choice

if(selection==1)  //if user enters 1

{  //computes area of square by calling findSquareArea

findSquareArea();  //function call to the findSquareArea function

}  

else if(selection==2)  //if user enters 2

{  //computes area of circle by calling findCircleArea

findCircleArea();  //function call to the findCircleArea function

}  

else if(selection==3)   //if user enters 3

{  //computes area of triangle by calling findTriangleArea

findTriangleArea();  //function call to the findTriangleArea function

}  

else if(selection==4)   //if user enters 4

{  

cout<<"\nTerminating!!.";  //exits after displaying this message

break;

}

else  // displays the following message if user enters anything other than the given choices

{

cout<<"\nInvalid selection";  //displays this message

}

}

while(1);  

}  

void findSquareArea(){  //function definition. this function has no parameters

float area=0.0;  //variable to store the area of square

float side=0;  //local variable of this method that stores value of side of square

cout<<"\nLength of side: ";  //prompts user to enter length of side

cin>>side;  //reads value of side from user

area=side*side;  //formula to compute area of square and result is assigned to area variable

cout<<"\nArea of Square: "<<area<<endl;   //displays are of the square

}  

void findCircleArea(){  //function definition. this function has no parameters

float area=0.0;  //variable to store the area of square

float radius=0.0;  //local variable of this method that stores value of radius of circle

cout<<"\nRadius of circle: ";  //prompts user to enter radius of circle

cin>>radius;  // reads input value of radius

area=PI*radius*radius;  //formula to compute area of circle

cout<<"\nArea of circle: "<<area<<endl;}  //displays are of the circle

void findTriangleArea(){  //function definition. this function has no parameters

   float area=0.0;  //variable to store the area of triangle

   float base=0.0;  //local variable of this method that stores value of base of triangle

   float height=0.0;  //holds value of height of triangle

cout<<"\nHeight of Triangle: ";  //prompts user to enter height

cin>>height;  //reads input value of height

cout<<"\nBase of Triangle: "; //prompts user to enter base

cin>>base;  //reads input value of base

area=0.5*height*base;  //computes area of triangle and assign the result to area variable

cout<<"\nArea of Triangle: "<<area<<endl;  //displays area of triangle

}

Explanation:

The program is modified as above. The prototypes for the four functions that are named as :

void displayMenu();  to display the Menu of choices and call relevant function to compute area

void findSquareArea();  To compute area of square

void findCircleArea(); To compute area of circle

void findTriangleArea();  To compute area of triangle

Note that these methods have no parameters and their return type is void. These 4 methods prototypes are placed above main() function.

Next the function definitions (consisting of a function header and initially empty body) for the four functions are written and placed below main() For example definition of findTriangleArea() is given below:

void findTriangleArea()

{

}

Next the code in the main is moved to the relevant methods. Then variables selection=0;  is moved to displayMenu method,  radius=0.0 to findCircleArea method , side=0; to findSquareArea float area=0.0;  to each method, float height=0.0;  and float base=0.0; to findTriangleArea method.

The relevant code moved to each method is shown in the above code.

The definition for the named constant PI is moved out of main and placed above the main function. const keyword before datatype of PI variable shows that PI is declared constant and its value is initialized once only to 3.14159.

Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for the given program with one call to inc_num_kids():

Answers

Answer:

This is the instance method inc_num_kids()

def inc_num_kids(self):

       self.num_kids += 1

Explanation:

The first line is the definition of function inc_num_kids() which has a parameter self. self is basically an instance of  class PersonInfo

self.num_kids += 1 this statement incremented the data member num_kids by 1. This means that the instance method inc_num_kids, using instance self, increments the value of num_kids data member by 1.

The complete program is as following:

class PersonInfo:  #class name PersonInfo

   def __init__(self):   #constructor of the class

       self.num_kids = 0  # data member num_kids

   def inc_num_kids(self):  # method inc_num_kids

       self.num_kids += 1  #increments num_kids by 1

person1 = PersonInfo()  #creates object person of class PersonInfo

print('Kids:', person1.num_kids)  # prints num_kids value before increment

person1.inc_num_kids()  #calls inc_num_kids method to increment num_kids

print('New baby, kids now:', person1.num_kids) #prints the value of num_kids after increment by inc_num_kids method

The person1 object first access the initial value of num_kids initialized by the constructor. So the first value of num_kids is 0. self.num_kids = 0  This statement assigns the value 0 to num_kids data member. Next the method inc_num_kids() using the object person1. Now when this method is called the value of data member num_kids is incremented to 1.

So previously the value was 0 which now increments by 1 and becomes 1. Last print statement displays this new value which is incremented by the inc_num_kids() method.

Hence the output is:

Kids: 0

New baby, kids now: 1

The program along with its output is attached.

In this exercise we have to use the knowledge of computational language in python to describe a code, like this:

The code can be found in the attached image.

To make it easier the code can be found below as:

class PersonInfo:  

  def __init__(self):  

      self.num_kids = 0  

  def inc_num_kids(self):  

      self.num_kids += 1  

person1 = PersonInfo()

print('Kids:', person1.num_kids)  

person1.inc_num_kids()

print('New baby, kids now:', person1.num_kids)

See more about python at brainly.com/question/26104476

Which is the first step in the process of reading materials critically

Answers

Answer:

SQRRR or SQ3R is a reading comprehension method named for its five steps: survey, question, read, recite, and review. The method was introduced by Francis P. Robinson, an American education philosopher in his 1946 book Effective Study. The method offers a more efficient and active approach to reading textbook material

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.

Other Questions
find the maximum value of c=6x+2y Read the excerpt from Amy Tans essay Mother Tongue. I know this for a fact, because when I was growing up, my mothers limited English limited my perception of her. I was ashamed of her English. I believed that her English reflected the quality of what she had to say. That is, because she expressed them imperfectly her thoughts were imperfect. the answer is to inform readers based on Tans childhood experience What is the purpose of this text? to inform readers based on Tans childhood experience to persuade readers to speak a different way to inform readers of Tans mothers feelings to persuade readers that Tans mother is intelligent I neeed help pls answe them plssss what comes after letter "A'? Select the correct answer.Listen to the descriptionand select the term that it describes..la recuperacinOB. la mitigacinOc. la conservacinOD. la preparacinResetNext Think about the information presented in the video. How has Brazil tried to ease poverty in its largest city? What are some benefits of this plan? What are some drawbacks? Propose one other way that Brazil might help citizens who live in favelas. Tristan wants to buy a car and has a choice between two different banks. One bank is offering a simple interest rate of 3% and the other bank is offering a rate of 2.5%compounded annually. If Tristan decides to deposit $7,000 for 4 years, which bank would be the better deal? Have Have! Always strength and hope! We are what our soul reaches! Have courage! Get moving! And the future you can ... Conquer! I feel the universe against me, I can't find a way to be happy I lost the battle, but this is not my end. From today, for what I want I will fight, my dreams will again pursue ... And I promise that I will never, ever give up! If you fail, don't fear, it doesn't matter ... How many times you fall, if you manage to stop. So I want to fall, stand up and learn to use my power! Have Have! Always strength and hope! You must have confidence in you! Don't let yourself be controlled! Don't be afraid to fly! Have Have! Always strength and hope! We are what our soul reaches! Have courage! Get moving! And the future you can ... Conquer! I will not bow before you! Even if you want to make me happy, you take away the things that are part of me. I will never ignore my heart again, because that was not the solution ... With pain, I learned this lesson! Faced with fear, you choose! It is simple! There are only two options ... Fight or you give up! But if you want to win, you will have to risk and fight until the end! Have Have! Always strength and hope! You must have confidence in you! Don't let yourself be controlled! Don't be afraid to fly! Have Have! Always strength and hope! We are what our soul reaches! Have courage! Get moving! And the future you can ... Conquer! Per Chevrons 3Q 2013 filing, what was the percentage change in the cost of purchased oil products when comparing nine months ended September 30, 2013 versus the same period in 2012? Financial Statements of a Manufacturing FirmThe following events took place for Focault Inc. during July 20Y2, the first month of operations as a producer of road bikes: Purchased $320,000 of materials Used $275,000 of direct materials in production Incurred $236,000 of direct labor wages Applied factory overhead at a rate of 75% of direct labor cost Transferred $652,000 of work in process to finished goods Sold goods with a cost of $630,000 Sold goods for $1,120,000 Incurred $252,800 of selling expenses Incurred $100,000 of administrative expensesA. Prepare the July income statement for Focault. Assume that Focault uses the perpetual inventory method.Focault Inc. Income StatementFor the Month Ended July 31Revenues $Cost of Goods SoldGross Profit $Selling and administrative expenses: Selling Expenses $Administrative ExpensesTotal selling and administrative expensesIncome from Operations $B. Determine the inventory balances at the end of the first month of operations.Materials inventory, July 31 Work in process inventory, July 31 Finished goods inventory, July 31 Unequal reproductive success ______.Group of answer choicescan lead to a population being less well adapted to its environmentcan lead to natural selectionalways decreases the size of a populationdoes not affect the frequency of expression of traits in succeeding generations of a populationincreases variation List the cereals that you eat. do you grow cereals you eat ? if yes draw a chart to show the stages in growing them. if notdraw a chart to show how these cereals reach you from the farmers who grpw them I don't understand this question. Could someone please help me? Why do you think the landscape varies so much throughout the United States? I wish to have $10,000 at the end of 8 yers in a bank offering a simple interest rate of 7.5% per year. How much should I deposit in the bank THIS IS URGENT! PLEASE ANSWER! I REALLY NEED HELP! :((( :c :'( *crys Suppose the weather forecast calls for a 60% chance of rain each day for the next 3 days. What is the probability that it will NOT rain during the next 3 days um aluno tinha uma quantidade de questoes para resolver se ja resolveu a quinta parte da sua tarefa ento a razo entre o numero de questoes resolvidas e o numero restante de questoes nessa ordem a) 1/20 b)1/5 c)1/4 d)4 e)5 Which of the following Functions is NOT Linear? A:f(x)=x+0.5 B:F(x)=-x+0.5 C: F(x)=x^2-0.5 D: f(x)=0.5x Which sentence from "Island of Hope, Island of Tears" is written using a cause-and-effect text structure? Her brother placed a housework-wanted ad in a local paper, and Katherine was soon hired as a governess with a wealthy family. After a brief courtship, he and Vida Dixon married and sailed to the United States in 1923. His brother Salvatore followed in 1908 and their siblings Antonio, Maria Anna, and Angelina joined them in 1913. The Sicurella family typified the kinds of professions many Italian immigrants undertook once they came to America in the early 1900s. Simplify the polynomial expressions by combining like terms, and then multiply the resultingbinomial expressions to find their product.(6x - 9 - 2x)(8 + 5x - 5)