Question

In: Computer Science

HW4: Practicing function definition and invocation. File access is also implemented. 1) Define a function "converT()"...

HW4: Practicing function definition and invocation. File access is also implemented. 1) Define a function "converT()" that can take a file name, reads line by line to convert temperatures, and returns line by line. Each line in a file begins with a temperature in number {integer or floating point}, followed by one of the temperature unit {"F", "f", "C", "c"}. If "F" or "f", convert the temperature to Celsius. If "C" or "c", convert the temperature to Fahrenheit. The format of returning value is a converted temperature followed by the converted temperature unit. For example, if a line is 45 F Then, the function returns 7.22 C 2) A file name is given by users. Assume that the file name is in fully-qualified-path. With this file name, the function is invoked. For example, it runs as follows: Enter file name: C:\\Users\\jyoon\\Desktop\\tempFile.data 45.00° in F is 7.22° in C 23.00° in c is 73.40° in F 11.00° in C is 51.80° in F 76.00° in F is 24.44° in C 88.00° in F is 31.11° in C 12.00° in F is -11.11° in C 1.00° in C is 33.80° in F Note that the file tempFile.data in the C:\Users\jyoon\Desktop directory contains 45 F 23 c 11 C 76 F 88 F 12 F 1 C SUBMIT: 1) Your source coding file. The file shows each every statement as shown the steps above, so the execution of the file shows the all print statements. 2) Screenshot(s) that may show the integrity of your work

Solutions

Expert Solution

Below is the screenshot of the code. Comments are given on every line.

Below is the input file:

Below is the output:


Related Solutions

Convert this code written in Python to Java: # Definition of a function isprime(). def isprime(num):...
Convert this code written in Python to Java: # Definition of a function isprime(). def isprime(num):     count=2;     flag=0;     # Loop to check the divisors of a number.     while(count<num and flag==0):         if(num%count!=0):             # Put flag=0 if the number has no divisor.             flag=0         else:             # Put flag=1 if the number has divisor.             flag=1         # Increment the count.         count=count+1     # Return flag value.     return flag # Intialize list. list=[]...
a.) Review the structure and function of a GPCR. b.) Define signal transduction—include in the definition...
a.) Review the structure and function of a GPCR. b.) Define signal transduction—include in the definition a listing of all components necessary to carry out this process c.) Describe the function(s) of signal transduction. Be specific. d.) Describe the process of desensitization a GPCR goes through. e.) Some techniques involved in these types of analyses might be protein separation, gel electrophoresis, Western blotting, calcium assays and PCR. Choose one of the five mentioned techniques and detail the theory behind it...
1. Download the EXCEL file: Access Exercise Tables 2. Open a new blank database in ACCESS...
1. Download the EXCEL file: Access Exercise Tables 2. Open a new blank database in ACCESS and name it “Exercise-Your Name” where you replace Your Name with your name. 3. Import each worksheet in the EXCEL file into ACCESS as a separate table as follows: a. External Data Tab -> Import Excel icon b. In the dialog box browse for the destination of the excel file you saved in step 1, it should default to “import the source data in...
Define the following function f(n) = 5(2^n)-(2^(n-1)), n ≥ 1. Write a recursive definition for the...
Define the following function f(n) = 5(2^n)-(2^(n-1)), n ≥ 1. Write a recursive definition for the function f(n)? Consider the following recurrence: an= 2an-1 + 3 (where a1 = 1). Compute the values of an for n ≤ 5. Find a solution for the recurrence definition and validate its correctness. Consider the following recurrence: an=2an-1 +an-1an-2 (where a1 = 1). Compute the values of an for n ≤ 5.
QUESTION 1. Access the glossary (“Master Glossary”) to answer the following: According to the definition for...
QUESTION 1. Access the glossary (“Master Glossary”) to answer the following: According to the definition for inventory, what are the three characteristics of tangible personal property that qualify items to be classified as inventory? What is specifically excluded from being defined as inventory? QUESTION 2. According to ASC 470-40-05-02, what is a sale with a repurchase agreement considered? What term is often used to describe these type of transactions? (hint: it’s in the textbook in Chapter 8 and I discussed...
Using Python create a script called create_notes_drs.py. In the file, define and call a function called...
Using Python create a script called create_notes_drs.py. In the file, define and call a function called main that does the following: Creates a directory called CyberSecurity-Notes in the current working directory Within the CyberSecurity-Notes directory, creates 24 sub-directories (sub-folders), called Week 1, Week 2, Week 3, and so on until up through Week 24 Within each week directory, create 3 sub-directories, called Day 1, Day 2, and Day 3 Bonus Challenge: Add a conditional statement to abort the script if...
Given the following Scheme definition: (define x '(define (fac n) (if (= n 0) 1 (*...
Given the following Scheme definition: (define x '(define (fac n) (if (= n 0) 1 (* n (fac (- n 1)))))) (This does not define the factorial function fac, but the variable x.) Write Scheme expressions in terms of x that would have the effect of extracting the following expressions: (fac n) 0 (- n 1) The second occurrence of fac. The last occurrence of n. E.g., the expression (car x) would extract define.
Test 1. 1. Define Accounting –      a. based on the PICPA definition      b. based...
Test 1. 1. Define Accounting –      a. based on the PICPA definition      b. based on the AICPA definition 2. What is the purpose of accounting? 3. Why do countries have different accounting standards? Test 2. From the given data below, determine if 1. the company is liquid, compute for      a. working capital     b. the liquidity ratio 2. if the company is solvent, compute for the solvency ratio 3. if the company is profitable, compute for the...
Define a function file_to_hist() which takes a string representing a filename, opens the file, reads its...
Define a function file_to_hist() which takes a string representing a filename, opens the file, reads its contents, closes the file,* and returns a histogram based on the letter frequencies in the given file. If no such file exists, your function should return an empty histogram (i.e., an empty dictionary {}). So for example, if the file nash.txt was in the same directory as char_hist3.py and had the following contents: I have never seen a purple cow, And I never hope...
1).Modify the project so that records are inserted into the random access file in ascending order...
1).Modify the project so that records are inserted into the random access file in ascending order using an insertion sort methodology with the Social Security Number acting as the key value. This requires defining the method compareTo() in the Personal and Student classes to be used in a modified method add() in Database. The method finds a proper position for a record d, moves all the records in the file to make room for d, and writes d into the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT