Unit 10 Homework Pt1420

In: Computers and Technology

Submitted By vzo36683
Words 610
Pages 3
Unit 10 Assignment Homework PT1420 Intro to Programming
True or False
1. When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it. False
2. In most languages, when you open an output file and that file already exists on the disk, the contents of the existing file will be erased. True
4. The purpose of an EOF marker is to indicate where a field ends. Files typically contain several EOF markers. False
5. When an input file is opened, its read position is initially set to the first item in the file. True
Algorithm Workbench
1. Design a program that opens an output file with the external name my_ name. dat, writes your name to the file, and then closes the file.
Declare an internal name for an output file.
2 Declare OutputFile myFile
3
4 // Declare the variable to hold values
5 // that will be read from the file
6 Declare String name
7
8 // Open a file named my_name.dat on
9 // the disk
10 Open myFile “my_name.dat”
11
12 // Write your name to the file
13 Write myFile “Your Name”
14
15 // Close the file
16 Close myFile
2. Design a program that opens the my_ name. dat file that was created by the algo-rithm in question 1, reads your name from the file, displays the name on the screen, and then closes the file.
Declare InputFile myName
Declare String name
Open myName "my_Name.dat"
Display "Your name is: "
While NOT eof (myName)
Read myName name
Display name
End While
Close myName
3. Design an algorithm that does the following: Opens an output file with the external name number_ list. dat, uses a loop to write the numbers 1 through 100 to the file, and then closes the file.
Declare OutputFile numberList
Declare Integer i
Open numberList "number_list.dat"
For i = 1 To 100
Write myFile i
Next i
End For
Close…...

Similar Documents

Pt1420 Unit 8 Assignment 1: Homework

...If it is not properly initialized, it will not contain the correct total. 9. What is the advantage of using a sentinel? The advantage of using a sentinel is that when you are processing a long list of values with a loop a sentinel marks the end of a list of items. There is no limit to how many times a loop can execute. 10. Why must the value chosen for use as a sentinel be carefully selected? The value of a sentinel needs to be carefully selected because it can’t be mistaken as a regular value in the list. Algorithm Workbench: 3. // Declare a counter variable. Declare Integer // Constant for the maximum value Constant Integer MAX_VALUE = 100 //Display the multiples of 10 from 0 through 100 For counter = 0 to MAX_VALUE Display counter End For   4. //Declare Integer number Declare an accumulator variable Declare Integer total = 0 Declare Integer counter For counter = 1 to 10 Display “Enter a number.” Input number Set total = total + number End For Display “The total is”, total 9. Declare Integer count For count < 50 Display “The count is “, count Set count = 1 To 50 End For 10. //Declare integer count While count...

Words: 303 - Pages: 2

Pt 1420 Unit 10 Homework

...Introduction to Programming Unit 10 Assignment 1 Short Answer 1. * Open the file – Opening the file creates a connection between the file and a program; this allows the program to read data from the file. * Process the file – Data is either read from the file or written to the file * Closing the file – The file must be closed when a program is finished using it. Closing the file disconnects the file from the program. 2. The file must be closed so the program will force any unsaved data in the buffer to be written to the file. 4. The file will not be erased, and any new data will be written at the end of the file’s current contents. 5. The program will create a new file. Algorithm Workbench 1. Declare OutputFile myFile Open myFile “my_name.dat” Write myFile “fatima” Close myFile 2. Declare InputFile myFile Declare String name1 Open myFile “my_name.dat” Read myFile name1 Close myFile Display ”Hello! My name is,” 3. Declare OutputFile numberList Declare Integer counter = 1 Open numberList “number_list.dat” For counter = 1 to 100 Write numberList, counter Next counter End For Close numberList 4. Declare InputFile number_list Declare Integer myNumber Open number_list ”number_list.dat" Display "Here are the numbers: " While NOT eof (number_list) Read numberList myNumber Display myNumber End While Close myName Programming Exercise Pg. 410 1.......

Words: 291 - Pages: 2

Pt1420 Unit 3 Homework

...* 2 = 2*2= 4 c. Set result = y / x = 8/4= 2 d. Set result = y – z = 8-2= 6 5. Write a pseudocode statement that declares the variable cost so it can hold real numbers. Floating-point variable cost 6. Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0. Declare Real price = 99.95 Display “The original price.” Input originalPrice Display price 7. Write a pseudocode statement that assigns the value 27 to the variable count. Count:=27 8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. Declare Integer total= 0 Set total= 10+14 9. Write a pseudocode statement that subtracts the variable downPayment from the variable total and assigns the result to the variable due. Declare Integer downPayment Declare Integer total Declare Integer due Set due= total-downPayment 10. Write a pseudocode statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable totalfee. The variable totalFee First make the variables Real numbers Example Dim subtotal as Double =0 The statement asked for in the question will appear as totalFee = subtotal * 0.15 Programming Exercise 6. Sales Tax Design a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should......

Words: 715 - Pages: 3

Pt1420 Unit 10

...PT1420 Unit 10 Assignment Homework True or False 1. When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it. False 2. In most languages, when you open an output file and that file already exists on the disk, the contents of the existing file will be erased. True 4. The purpose of an EOF marker is to indicate where a field ends. Files typically contain several EOF markers. False 5. When an input file is opened, its read position is initially set to the first item in the file. True Algorithm Workbench 1. Design a program that opens an output file with the external name my_ name. dat, writes your name to the file, and then closes the file. Declare an internal name for an output file. 2 Declare OutputFile myFile 3 4 // Declare the variable to hold values 5 // that will be read from the file 6 Declare String name 7 8 // Open a file named my_name.dat on 9 // the disk 10 Open myFile “my_name.dat” 11 12 // Write your name to the file 13 Write myFile “Your Name” 14 15 // Close the file 16 Close myFile 2. Design a program that opens the my_ name. dat file that was created by the algo-rithm in question 1, reads your name from the file, displays the name on the screen, and then closes the file. Declare InputFile myName Declare String name Open myName "my_Name.dat" Display "Your name is: " While NOT eof (myName) Read myName name Display......

Words: 607 - Pages: 3

Pt1420 Unit 3 Assignment 1 Homework

...Unit 3 Assignment 1 Homework Short Answer: 5. What two thing must you normally specify in a variable declaration? * You must specify the variable type and an identifier. * int n; // type - int, identifier - n 6. What value is stored in uninitialized variables? * is a variable that is declared but is not set to a definite known value before it is used. Algorithm Workbench pg71-72 3) Write assignment statements that perform the following operations with the variable a, b and c. a) Adds 2 to a and stores the result in b. { b = 2 + a } b) Multiplies b by 4 and stores the result in a. { a = b * 4} c) Divides a by 3.14 and stores the result in b. { b = a MOD 3.14 } d) Subtracts 8 from b and stores the result in a { a = 8 – b } 4) Assume the variables result, w, x, y and z are all integers, and that w=5, x=4, y=8 and z=2. What value will be stored in result in each of the following statements? a) 12 = x + y b) 4 = z * 2 c) 2 = y / x d) 6 = y – z 5) Write a pseudocode statement that declares the variable cost so it can hold a real numbers. Dim cost1 As Double = 0 6) Write pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0. Dim cost1 As Integer = 0 7)Write a pseudocode statement that assigns the value 27 to the variable count. Dim count As Integer = 27 8) Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. Total = 10 + 14 9) Write a......

Words: 577 - Pages: 3

Pt1420 Homework

...PT1420 Melson, Brain Unit 4 Assignment 1: Homework Learning Objectives and Outcomes * Explain the importance of separating code into modules for efficiency. * Use flowcharts and pseudocode to represent program modules. * Describe the impact of program modules on variables—variable scope. * Describe the necessity of having compatible arguments in module parameters. * Evaluate the various program modules. Assignment Requirements Do the following problems: * Short Answer 1-7 on page 111 1. How do modules help you to reuse code in a program? a. Help reduce the duplication of code within a program, this benefit of using modules is known as code reuse because you are writing the code to perform a task once and then reuse it each time you need to perform a task. 2. Name and describe the two parts that a module definition has in most languages. a. A header and a body. The header indicates the starting point of the module, and the body is a list of statements that belong to the module. 3. When a module is executing, what happens when the end of the module is reached? a. When a module is called, the computer jumps to that module and executes the statement in the module's body. Then, when the end of the module is reached, the computer jumps back to the part of the program that called the module, and the program resumes execution at that point. 4. What is a local variable? What statements are able to access a local variable? ...

Words: 1156 - Pages: 5

Pt1420 Unit 1 Assignment 1 Homework

... The typical hardware associated with a computer includes but are not limited to input devices such as mice, keyboards and webcams. Output devices like monitors, speakers and printers and your different types of memory (CPU, RAM, SSDs.) The computer’s data storage process consists of tiny electrical power charges in microscopic capacitors. When a computer is turned off the capacitors that your data is stored on lose their charge which is why computer memory goes blank when it is off. For data that is stored for longer periods of time, it is stored as a magnetic pattern on a spinning disk. A program is a set of instructions that a computer follows in order to perform a task. A program is run by the computer’s CPU or Central Processing Unit. Each instruction in a program tells the CPU to perform a specific operation. Machine Language: Language that CPU understands. It is always written in binary. Assembly Language: Language that consists of short words known as mnemonics. It was created because it was impractical for people to write programs in machine language. High-Level Language: Allows people to create powerful and complex programs without knowing how the CPU works, and without writing large numbers of low-level instructions. Compiler: Program that translates a high-level language into a separate machine language program. Interpreter: Program that both translates and executes the instructions in a high-level program. As described earlier in this paper, I......

Words: 287 - Pages: 2

Pt1420 Unit 5 Assignment 1. Homework

...and assigns 1 to the variable c if the variable a is less than 10. 3. Design an If- Then- Else statement ( or a flowchart with a dual alternative decision structure) that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. If a <= 10 Then Display “Assign 0 to b” End If 4. The following pseudocode contains several nested If- Then- Else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and indentation. If score <= 60 Then Display " Your grade is F." Else If score <=70 Then Display " Your grade is D." Else If score <= 80 Then Display " Your grade is C." Else If score <= 90 Then Display " Your grade is B." Else Display " Your grade is A." End If End If End If End If 5. Design nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2. If amount1 <= 10 Then Display “The greater of amount1” Else If amount2 >= 100 Then Display “The greater of amount2” End If End If Programming Excercises: 1.Roman Numerals Design a program that prompts the user to enter a number within the range of 1 through 10. The program should display the Roman numeral version of that num-ber. If the number is outside the range of 1 through 10, the program should display an error message. 2.Areas of......

Words: 686 - Pages: 3

Pt1420 Unit 5 Assignment 1. Homework

...and assigns 1 to the variable c if the variable a is less than 10. 3. Design an If- Then- Else statement ( or a flowchart with a dual alternative decision structure) that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. If a <= 10 Then Display “Assign 0 to b” End If 4. The following pseudocode contains several nested If- Then- Else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and indentation. If score <= 60 Then Display " Your grade is F." Else If score <=70 Then Display " Your grade is D." Else If score <= 80 Then Display " Your grade is C." Else If score <= 90 Then Display " Your grade is B." Else Display " Your grade is A." End If End If End If End If 5. Design nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2. If amount1 <= 10 Then Display “The greater of amount1” Else If amount2 >= 100 Then Display “The greater of amount2” End If End If Programming Excercises: 1.Roman Numerals Design a program that prompts the user to enter a number within the range of 1 through 10. The program should display the Roman numeral version of that num-ber. If the number is outside the range of 1 through 10, the program should display an error message. 2.Areas of......

Words: 686 - Pages: 3

Programming Unit 10 Homework

...Unit 10 Assignment 1: Homework Short Answer Ch10 #1 Describe the three steps that must be taken when a file is used by a program. Open the file, Process the file, Close the file #2 Why should a program close a file when it’s finished using it? By closing a file, any unsaved data that is held in the buffer is saved to its file. Also, when a program closes files that are no longer being used, the files will not take up more of the operating system's resources than necessary. #4 If an existing file is opened in append mode, what happens to the file’s existing contents? In most languages, when you open an output file and that file already exists on the disk, the contents of the existing file will be erased. #5 In most languages, if a file does not exist and a program attempts to open it in append mode, what happens? The Program will create a new file Algorithm Workbench Ch10 #1 Design a program that opens an output file with the external name my_ name. dat, writes your name to the file, and then closes the file. Declare an internal name for an output file. Declare outputFile myFile // Declare the variable to hold values // that will be read from the file Declare String name // Open a file named my_name.dat on // the disk Open myFile “my_name.dat” // Write your name to the file Write myFile “Your Name” // Close the file Close myFile #2 Design a program that opens the my_ name. dat file that was created by the algo-rithm in question......

Words: 651 - Pages: 3

Pt1420 Programming Unit 10 Research & Homework

...Unit 10: Homework and Research Assignment Definition Decision Structure - allows a program to perform actions only under certain conditions. Boolean expression - expressions that can be evaluated as either True or False Iteration - is the repetition of a block of statements within a computer program. Counter-controlled repetition structure - used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends. Many programming tasks are repetitive, having little variation from one item to the next.  Condition controlled - Most programming languages have constructions for repeating a loop until some condition changes. Note that some variations place the test at the start of the loop, while others have the test at the end of the loop.  Pre – test loop - the condition gets evaluated at the beginning of the loop cycle. Therefore, the body of the loop will not get executed if the condition does not hold the very first time. Post – Test loop - the loop condition gets evaluated at the end of the loop cycle. Therefore, the body of the loop will get executed at least once, regardless of the condition. This is a major difference between a pretest loop and a posttest loop. You may choose a posttest loop if the problem description justifies the body of the loop be executed at least once. Repetition Sequence/ Set of statements - A repetition structure causes a statement or set of statements to......

Words: 1912 - Pages: 8

Pt1420 Unit 10

...Timothy Knox 8/21/2015 Dr. North Unit 10 10.1.1 TCP can connect two hosts with the capability to retransmit dropped packets, maintain ordering, and check for errors. A TCP connection is established with a three-way handshake in which a connection is established and acknowledged. What are the three messages that form this handshake sequence? Why is this important for establishing the connection? Use your textbook and Internet research to compose your answer. The messages that are used to form the handshake are SYN, SYN-ACK, and ACK. They are important because it allows for both ends to initiate and communicate using different TCP sockets at once. 10.1.2 By establishing a TCP connection, you allow one host to verify expected communication to and from the connected host. This provides two important features: windowing/sequencing and error checking/recovery. Windowing and sequencing are used to determine whether messages have been seen and are delivered in the correct order to the recipient. Error checking makes sure that all the packets are delivered as expected, providing reliability. Why are reliability and sequencing important in message delivery? Give an example of when each would be necessary. Its important because it allows for the organization of multiple messages so that the right message is sent in its proper order. Sequencing is the other important part because it makes sure things are in order and also that they are received in the right time frame......

Words: 530 - Pages: 3

Pt1420 Unit 1 Homework

...Jonathan Ford Intro to Programming Unit 1 Homework 4/13/16   1. Why is the CPU the most important component in a computer?       a. Without the CPU, the computer could not run software. The CPU is the part of the computer that actually runs the programs. (pg. 3)   2. What number does a bit that is turned on represent? What number does a bit that is turned off represent?       b. 1 represents a bit that is turned ON. 0 represents a bit that is turned OFF. (pg. 8)   3. What would you call a device that works with binary data?       c. A device that works with binary data is called a DIGITAL device. (pg. 11)   4. What are the words that make up a high-level programming language called?       d. The words that make up a high-level programming language are known as KEY WORDS or RESERVED WORDS. (pg. 17)   5. What are the short words that are used in assembly language called?       e. The short words that used in assembly language are called MNEMONICS. (pg. 14)   6. What is the difference between a compiler and an interpreter?       f. A COMPILER is a program that translates a high-level language program into a separate machine language program. An INTERPRETER is a program that both translates and executes the instructions in a high-level language program. (pg. 17-18)   7. What type of software controls the internal operations of the computer’s hardware?       g. An operating system controls the internal operations of the computer’s hardware....

Words: 254 - Pages: 2

Pt1420 Unit 1 Assignment 1 Homework

...Unit 1 Assignment 1: Homework Short Answer 1. Why is the CPU the most important component in a computer? The CPU is the most important part of the computer is that it runs the programs, without it a computer cannot run software. 2. What number does a bit that is turned on represent? What number does a bit that is turned off represent? A bit that is on is represented by the digit 1 and a bit that is off is represented by the digit 0. 3. What would you call a device that works with binary data? A digital device is any device that works with binary data. 4. What are the words that make up a high-level programming language called? Key words or reserved words have specific meaning and purpose in the programming language. 5. What are the short words that are used in assembly language called? Assembly language uses short words that are known as mnemonics. 6. What is the difference between a compiler and an interpreter? Compiler is a program that translates high-level language program into a separate machine language program. An interpreter is a program that both translates and executes the instructions in a high-level language program. 7. What type of software controls the internal operations of the computer’s hardware? An operating system is the most fundamental set of programs on a computer. The operating system controls the internal operations of the computer’s hardware, manages all of the devices connected to the computer, allows data to be saved to and......

Words: 272 - Pages: 2

Pt1420 V1 Unit 2 Assignment 1: Homework

...Unit 2 Assignment 1 Pt1420 Unit 2 Assignment 1: Homework Kenneth D. Davis Intro to Programming Short Answer 1. What does a professional programmer usually do first to gain an understanding of a problem? Interview the customer 2. What is pseudocode? Fake Code 3. Computer programs typically perform what three steps? 1. Input is received. 2. Some process is performed on the input. 3. Output is produced. 4. What does the term “user- friendly” mean? The term user- friendly is commonly used in the software business to describe pro-grams that are easy to use. Programs that do not display adequate or correct instruc-tions are frustrating to use, and are not considered user- friendly. One of the simplest things that you can do to increase a program’s user- friendliness is to make sure that it displays clear, understandable prompts prior to each statement that reads keyboard input. 5. What two things must you normally specify in a variable declaration? You must specify the variable type and an identifier 6. What value is stored in uninitialized variables? Some languages assign a default value as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values. Algorithm Workbench 1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height. Set height = 72” Display ‘Enter your Height at Age 21’ Input hEIGHT Display ‘Enter your Height......

Words: 319 - Pages: 2