Pt 1420 Homework

In: Computers and Technology

Submitted By scho
Words 296
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.
Declare Integer number
Declare InputFile numberFile
Open numberFile “numbers.dat”
Display “Here are the numbers: “
While NOT eof(numberFile)
Read numberFile (number)
Display number
End While
Close numberFile
2.
Declare String name
Declare Integer counter = 0
Declare InputFile nameFile
Open nameFile (names.dat”)
While NOT eof(nameFile)
Read nameFile name
Set counter = counter + 1
End While…...

Similar Documents

Pt 1420 Unit 4

...Unit 4 Research 1: Using Global Variables Advantages of using Global Variables * Global variable belongs to every function in the program. * Avoid passing frequently-used variables between several functions. * A global variable is accessible in every scope. * A global variable can potentially be modified from anywhere. * It can be accessed from any other files using extern. Disadvantages of using Global Variables * Non-locality -- Source code is easiest to understand when the scope of its individual elements is limited. Global variables can be read or modified by any part of the program, making it difficult to remember or reason about every possible use. * Implicit coupling -- A program with many global variables often has tight couplings between some of those variables, and couplings between variables and functions. Grouping coupled items into cohesive units usually leads to better programs. * Concurrency issues -- if globals can be accessed by multiple threads of execution, synchronization is necessary (and too-often neglected). When dynamically linking modules with globals, the composed system might not be thread-safe even if the two independent modules tested in dozens of different contexts were safe. * Namespace pollution -- Global names are available everywhere. You may unknowingly end up using a global when you think you are using a local (by misspelling or forgetting to declare the local) or vice versa. Also, if you ever have to......

Words: 384 - Pages: 2

Pt 1420 Final Study Guide

...List three examples of operating system software. Linux, OS X, and Microsoft Windows List three examples of application software.Microsoft Word, Adobe Photoshop, and Visual Studio Programs that make a computer useful for everyday tasks are known as application software What is used to translate high level language programs to machine language (or machine code)? Compiler What both translates and executes the instructions in a high level language program? What was the first programming language designed to perform complex math functions? Interpreter.Fortran Rules that are strictly enforced during compilation are called what?Syntax Rules What are violations of strictly enforced rules during compilation called?Syntax Errors Which will not prevent compilation, syntax or logical errors? Logic Errors Instead of binary numbers, assembly language uses short words for instructions known as what? Mnemonics Name a high level language you use in the course. Visual Basic The words that make up a high level programming language are known as what? Keywords Which runs faster a compiled or an interpreted program? Compiled Which language utilizes binary numbers like 01110000? Machine Language How many steps are in the Program Development Cycle and what are they? 1 - Design the Program2 - Write the Code3 - Correct Syntax Errors4 - Test the Executable Code 5 - Debug the Code What is an informal language that has no syntax rules and is not meant to be compiled or......

Words: 370 - 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

Pt 1420

...Assignment 6. A loop that has no way of stopping, and repeats until the program is interrupted. 7. A Do-While loop 8. A variable that is used to accumulate the total of a series of numbers. 9. A sentinel is a special value that marks the end of a list of items. 10. A sentinel value must be unique enough that it will not be mistaken as a regular value in the list. Algorithm 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   Research List three examples that show when a count-controlled loop is better than condition-controlled loop in programming? 1. It keeps a count of the number of times you want to use the program to input data 2. It only runs as many times as you have instructed the program to run 3. It will stop after the allotted time it has been instructed to 2.List three examples that show when a condition-controlled is better than......

Words: 297 - Pages: 2

Pt 1420

...1. Why is the CPU the most important component in a computer? The CPU stands for Central Processing Unit. It does all the processing for the entire system. Without it, your computer can't do anything. It has nothing to process information. It's just dead without it. 2. What number does a bit that is turned on represent? What number does a bit that is turned off represent? When a bit is turned on, it represents a "1". When it is turned off, it represents a "0". The exact value depends on where the bit is within the byte it is part of. In the binary number 0000 0001, the last bit is set to 1 and represents the number 1. 3. What would you call a device that works with binary data? Digital Data is data that is stored in binary, and 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? The words that make up a high-level programming language are known as key words or reserved words. 5. What are the short words that are used in assembly language called? Mnemonic 6. What is the difference between a complier and an interpreter? A compiler translates code from a source language (e.g. C, C++, and Java) to a target language, which can then be executed by a (virtual or physical) machine. An interpreter reads code in an interpreted language (e.g. PHP, Perl, and Java Script) and directly executes the contained instructions. 7. What type of software controls the internal operations......

Words: 293 - Pages: 2

Pt 1420 Unit 2 Homework

...Unit 2 Homework Short Answer Pg. 71 (1-4) 1.) Work directly with and interview the customer. 2.) Pseudocode is an informal language that has no syntax rules, and is not meant to be compiled or executed. 3.) Input is received, some process is performed on the input, output is produced. 4.) User-friendly means that something is easy for anyone, regardless of their level of experience, to use. Algorithim Workbench Pg. 71 (1-2) 1.) Declare Height as Integer Display “ Enter Height “ Input “ Height “ 2.) Declare Color as String Display “ Enter Color” Input “ Color “ Please view Visio Attachments for flow charts Programming Exercises Pg. 72 (1&4) 1.) Sub Main() Console.WriteLine("Mark Gutierrez") Console.WriteLine("123 Bonehead Lane") Console.WriteLine("702-555-555") Console.WriteLine("NSA") Console.ReadLine() End Sub End Module 4.) Module Module1 Sub Main() Dim gtotal As Double Dim taxamount As Double Dim subtotal As Double Dim tax As Double = 0.06 Dim item1 As Double Dim item2 As Double Dim item3 As Double Dim item4 As Double Dim item5 As Double Console.WriteLine("enter item #1 price") item1 = Console.ReadLine() Console.WriteLine("enter item #2 price") item2 = Console.ReadLine() Console.WriteLine("enter item #3 price") item3 =......

Words: 270 - Pages: 2

Pt 1420 Lab 6

...Module Module1 Sub Main() Dim mobileProvider As Integer = 0 Dim dataOption As Integer = 0 Dim dataPackage As Boolean = True Call inputOption(mobileProvider, dataOption, dataPackage) Console.WriteLine() Call displayProvider(mobileProvider) Call displayOption(mobileProvider, dataPackage) Console.ReadLine() Console.WriteLine(" Press Enter To Continue ") Console.ReadLine() End Sub Sub inputOption(ByRef mobileProvider As Integer, ByRef dataOption As Integer, ByRef dataPackage As Boolean) Console.Write(" Enter 1 for ATT, 2 for Sprint, and 3 for Verizon ") mobileProvider = Console.ReadLine() Console.WriteLine() Console.WriteLine(" Enter 1 If you want Data Package, or 2 If you do not ") dataOption = Console.ReadLine() Console.WriteLine() If dataOption = 1 Then dataPackage = True Else : dataPackage = False End If End Sub Sub displayProvider(ByVal mobileProvider As Integer) Select Case mobileProvider Case 1 Console.WriteLine(" You selected ATT ") Case 2 Console.WriteLine(" You selected Sprint ") Case 3 Console.WriteLine(" You selected Verizon ") End Select End Sub Sub displayOption(ByVal mobileProvider As Integer, ByVal dataPackage As Boolean) ...

Words: 256 - Pages: 2

Sd 1420

...Tarrin Thomas SD 1420 Unit 9 Assignment · Which of the following statements converts a double value d into a string s? · s = new Double(d).stringOf(); · s = String.stringOf(d); · s = (new Double(d)).toString(); · s = (Double.valueOf(s)).toString(); The answer is D · Assume Calendar calendar = new GregorianCalendar(). Which of the following statements will return the number of days in a month? · calendar.getActualMaximum(Calendar.DAY_OF_MONTH) · calendar.get(Calendar.MONTH_OF_YEAR) · calendar.get(Calendar.WEEK_OF_MONTH) · calendar.get(Calendar.WEEK_OF_YEAR) · calendar.get(Calendar.MONTH) The answer is E · Assume Calendar calendar = new GregorianCalendar(). Which of the following statements will return the week of the year? · calendar.get(Calendar.MONTH_OF_YEAR) · calendar.get(Calendar.WEEK_OF_YEAR) · calendar.get(Calendar.WEEK_OF_MONTH) · calendar.get(Calendar.MONTH) The answer is B · What will be the output of running the class Test with the following code lines? interface A { } class C { } class B extends D implements A { } public class Test extends Thread { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); if (b instanceof C) System.out.println("b is an instance of C"); } } class D extends C { } · b is an instance of A followed by b......

Words: 1250 - Pages: 5

Pt 1420

...PT 1420 Student Name:__________________ Introduction to Programming Winter 2014/2015 Instructor: Martin Remmele Unit 7 Homework Assignment Due by end of first break February 10, 2015 Learning Objectives and Outcomes NOTE: This section lists concepts and techniques to be understood from this unit. The actual assignment that you are to complete is found in the next section: “Assignment Requirements”. * Be able to Use pseudocode/flowcharts to represent repetition structures. * Be able to Create While, Do-While, and Do-Until conditional loops. * Be able to Describe the implications of an infinite loop. Assignment Requirements Complete the following exercises. An exercise that calls for an algorithm may be written in English as a series of steps. An exercise that calls for program statements may be written in a) the text’s pseudocode, b) your own preferred pseudocode notation or c) Visual Basic. (VB code can simply be typed into your Word document; it does not have to be created in the development environment.) The logic of the statements will be more important to the grade than the syntax. * Short Answer Review Questions 1-5, starting on page 213 (5 pts each) * Algorithm Workbench Review Questions 1, 2, 7, and 8, starting on page 213 (10 pts each) * Programming Exercises 1, 3, and 4, starting on page 214 (10 points each) Required Resources *...

Words: 310 - Pages: 2

Pt 1420 Unit 2 Assignment 1 Homework

...Short Answer 1. What does a professional programmer usually do first to gain an understanding of a problem? Check with customer for what their needs are and do an analysis using pseudocode when originally writing their programs out. By doing this, they do not have to take the time worrying with correct rules or with syntax errors. Many diagrams including "Work Break Down Structure", "Workflow Diagram" and "Class Diagrams" are some of the most common ones are used. Break the larger problem into independent sub-problems. Seek solution of each sub-problem. Test the solutions of each sub-problem. Combine all the tried and tested solutions together Apply the solution to the complex problem under consideration Documentation = Every step to prove testing + success 2. What is pseudocode? The word “pseudo” means fake, so pseudocode is fake code. It is an informal language that has no syntax rules, and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or “mock-ups” of programs 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 programs that are easy to use. 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......

Words: 795 - Pages: 4

Pt 1420 Unit 5 Assignment

...Short Answer 1. Explain what is meant by the term “conditionally executed”. Conditionally executed is called a single alternative decision structure because it provides only one alternative path of execution. The action is conditionally executed because it is performed only when a certain condition is true. 2. You need to test a condition and then execute one set of statements if the condition is true. If the condition is false, you need to execute a different set of statements. What structure will you use? I will use the “If” statement because it is a dual alternative decision structure. 3. If you need to a test the value of a variable and use that value to determine which statement or set of statements to execute, which structure would be the most straightforward to use? The case structure lets the value of a variable or an expression determine which path of execution the program will take. 4. Briefly describe how the AND operator works. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is True only when both sub-expressions are true. 5. Briefly describe how the OR operator works. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub-expressions is true. The following is an example of an If-Then statement that uses the OR operator: 6. When determining whether a number is inside a range, which logical operator is it...

Words: 957 - Pages: 4

Pt 1420 7.4 Flow Chart

...Module 3 Position Paper Jerry Wilkins ITT Technical Institute   There are many risks both health and environmental that take place when using hormones to genetically engineer food. According to the American Academy of Environmental Medicine (AAEM), several animal studies indicate serious health risks associated with genetically modified (GM) food. The AAEM has asked physicians to advise all patients to avoid GM foods. Numerous health problems increased after GMOs were introduced in 1996. The percentage of Americans with chronic illnesses and food allergies has gone up drastically. Reproductive disorders, autism, and digestive problems have steadily been on the rise as well. Although there is no sufficient research to confirm that genetically engineered foods are a contributing factor to these issues, there is still something about the process of genetically modifying the food that seems immoral and unhealthy. Between 1996 and 2008, US farmers sprayed an extra 383 million pounds of herbicide on GM food producing a "superweeds," which are resistant to the herbicide. This is causing farmers to use even more toxic herbicides every year. Not only does this create environmental harm, GM foods contain higher residues of toxic material. Roundup, for example, is linked with sterility, hormone disruption, birth defects, and cancer. GM crops and their associated herbicides can harm birds, insects, amphibians, marine ecosystems, and soil organisms. They reduce bio-diversity,......

Words: 575 - Pages: 3

Pt 1420

...Step 1: This program is most easily solved using just a few variables. Identify potential problems with the following variables declared in the pseudocode. Assume that the college has the ability to offer half credits. (Reference: Variable Names, page 39-40). Variable Name | Problem(Yes or No) | If Yes, what’s wrong? | Declare Real creditsTaken | No | | Declare Int creditsLeft | Yes | Data type should be Real | Declare Real studentName | Yes | Data type should be String | Constant Real credits Needed = 90 | Yes | Should be no space in variable name | Step 2: What is wrong with the following calculation? (Reference: Variable Assignment and Calculations, page 43). Set creditsLeft = creditsTaken – creditsNeeded Terms should be switched Step 3: Write the exact output you would expect from the following line of code if the user of the program enters “Nolan Owens”. (Reference: Displaying Items, page 40 – 41). Display “The student’s name is “, studentName The student’s name is Nolan Owens Step 4: Write the exact output you would expect from the following line of code if the user of the program enters a name of Nolan Owens and they have taken 20 credits so far. (Reference: Displaying Items, page 40 – 41). Display “The Network Systems Administration degree is awarded after 90 credits and “, studentName, “has “, creditsLeft, “left to take before graduation.” The Network Systems Administration degree is awarded after 90 credits and Nolan Owens has 70......

Words: 603 - Pages: 3

Pt 1420 Midterm

...What makes a computer useful for everyday tasks? Application Software Play audio for this term List three examples of operating system software. Linux OS X Microsoft Windows List three examples of application software Microsoft Word Adobe Photoshop Microsoft Visual Studio What is used to translate high level language programs to machine language (or machine code)? Compiler What both translates and executes the instructions in a high level language program? Interpreter Rules that are strictly enforced during compilation are called what? Syntax Rules What are violations of strictly enforced rules during compilation called? Syntax Errors Which will not prevent compilation, syntax or logical errors? Logic Errors What was the first programming language designed to perform complex math functions? Fortran Instead of binary numbers, assembly language uses short words for instructions known as what? Mnemonics Name a high level language you use in the course. Visual Basic  The words that make up a high level programming language are know as what? Keywords  When a CPU executes instructions in a program, it is known as what? The Fetch-Decode-Execute Cycle  Which runs faster a compiled or an interpreted program? Compiled  Which language utilizes binary numbers like 01110000? Machine Language  Which language utilizes commands like ADD A7? Assembly Language  What is the method...

Words: 1275 - Pages: 6

Pt 1420 Unit 5-1

...1. Conditionally executed is called a single alternative decision structure because it provides only one alternative path of execution. The action is conditionally executed because it is performed only when a certain condition is true. 2. I will use the “If” statement because it is a dual alternative decision structure. 3. The case structure lets the value of a variable or an expression determine which path of execution the program will take. 4. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is True only when both sub-expressions are true. 5. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub-expressions is true. The following is an example of an If-Then statement that uses the OR operator: 6. The AND operator would be the best to use to determine whether or not a number is within a given range. 7. A flag is a Boolean variable that signals when some condition exists in the program. When the flag is set to False, it indicates the condition does not exist. When the flag variable is set to True, it means the condition does exist. Algorithm Workbench 1. Y=20 Z=40 End If 2. B=0 C=1 End If 3. B=0 Else B=99 End if 4. If score < 60 Then Display “Your grade is F” Else If score < 70 Then Display “Your grade is D” Else If score < 80 Then 5. If amount1 > 10 and amount2 < 100 Then If......

Words: 401 - Pages: 2