Premium Essay

Pt1420

In:

Submitted By weezy704
Words 721
Pages 3
ALONZO DARGAN (17186943)
PT1420 Computer Programming Unit 7 Assignment 1: Homework
7 May 2014
Short Answers Page 213 1-5

1. Why should you indent the statements in the body of a loop?
Because by indenting the statements in the body of the loop you visually set them apart from the surrounding code. This makes your program easier to read and debug. 2. Describe the difference between pretest loops and posttest loops.
A pretest loop means to test its condition before performing an iteration A posttest loop means it performs an iteration before testing its condition. 3. What is a condition-controlled loop?
A condition-controlled loop uses a true/false condition to control the number of times that it repeats. 4. What is a count-controlled loop?
A count-controlled loop repeats a specific number of times. 5. What three actions do count-controlled loops typically perform using the counter variable? 1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.

Algorithm Workbench Review Questions 1,2,7, and 8 p. 213-214 1. Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as the product contains a value less than 100.
A- Declare number as integer While product < 100 Display “What is your number” Input number Product = number *10 Display “Your number is “, product End While 2. Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should

Similar Documents

Premium Essay

Pt1420

...PT1420 unit 1 homework 1. Software mainly directs and coordinates computer hardware. In its function, software directly provides instructions to the computer hardware and serves as input to another piece of software to facilitate computing. 2. Some basic computer hardware includes the motherboard, CPU, RAM, hard drive. 3. A computer stores data in clusters on the hard drive. Each cluster is a pie slice-looking area that holds a certain amount of data. The amount of data that can be stored in each cluster is dependent on the operating system. 4. A program tells the computer how to accept some type of input, manipulate that input, and spit it back out again in some form that humans find useful. 5. Machine Language is what essentially people normally call binary. Assembly Language is the next step up, using specific keywords and terms, and will require an assembler to convert into executable machine language. A high-level language is what most programmers’ use, because of its reconizability since it may contain some English terms that we humans can understand. To convert a high-level language to machine language, you'll need a compiler and linker. 6. A compiler takes all of the code and translates it into something a computer can understand. This compiled code is then executed or saved to a file to be executed at a later time. Interpreter takes code and translates it line by line and doesn't save the translated code in a file. 7. System software:  helps...

Words: 418 - Pages: 2

Premium Essay

Pt1420

...PT1420 - Midterm Study Guide Study online at quizlet.com/_cl08u 1. ...: How many times will this loop iterate Set = 1 While i 5 Display i end while 22. List three examples of application software: Microsoft Word Adobe Photoshop Microsoft Visual Studio 6. ...: How many times will this loop iterate Set = 1 While i Great Then < Less Then >= Greater Then or Equal 7 is false 5 < 7 Is True (5 > 7) or (10 > 3) is True (5 > 7) and (10 < 3) is False NOT (5 > 7 ) and (10 > 3 )is true because the NOT reverses the False Age < 10 and age > 60 Will never be true 55. What is the term that describes the part of the program that a variable can be accessed?: Scope What is the truth table for AND?: True AND True = True True AND False = False False AND False = False False AND True = False 34. 35. 56. 36. 57. What is the truth table for OR?: True OR True = True True OR False = True False OR False = False False OR True = True 58. 59. 60. What is the value of 2^3?: 2 2 2 = 8 What is the value of 4^2?: 4 * 4 = 16 What is the value of the expression 10-4*3/2+5?: 9. Multiply first, then divide, then subtract and finally add. What is used to check the relationship between two values?: Relational Operator What is used to translate high level language programs to machine language (or machine code)?: Compiler What makes a computer useful for everyday tasks?: Application Software What was the first programming language designed to perform complex math functions?:...

Words: 779 - Pages: 4

Premium Essay

Pt1420

...1. Script- Are distinct from the core code of the application, which is usually written in a different language, and are often created or at least modified by the end-user. Scripts are often interpreted from source code or bytecode, whereas the applications they control are traditionally compiled to native machine code. Program-The program has an executable form that the computer can use directly to execute the instructions. The same program in its human-readable source code form, from which executable programs are derived (e.g., compiled). 2. tempfile=/tmp/$$.$script cp $editfile $tempfile if vim $editfile then mv $tempfile bak.$(basename $editfile) echo "$script: backup file created" else mv $tempfile editerr echo "$script: edit error--copy of " \ "original file is in editerr" 1>&2 fi. 3. $ function perms () { > chmod u+x $1 > } a. When you are writing many shell scripts, it can get tedious to give many chmod commands. This function speeds up the process. b. $ function perms { > chmod u+x $* > } c. Put the function in the ~/.bash_profile and/or ~/.bashrc file to make it available each time you log in (using bash). d. Use source to execute the file you put the function in, for example, $ source ~/.bash_profile 4. A shell function will do nothing unless it is explicitly called by other code, typically in a shell script. A shell script is a runnable, executable process, which can call other shell scripts and/or functions. The...

Words: 309 - Pages: 2

Premium Essay

Pt1420

...Unit 1 Assignment 1 1. Why is the CPU the most important component in a computer? Without the CPU, the computer could not run software. The CPU is the part of the computer that actually runs the programs 2. What number does a bit that is turned on represent? What number does a bit that is turned off represent? 1 represents a bit that is turned ON. 0 represents a bit that is turned OFF. 3. What would you call a device that works with binary data? A device that works with binary data is called a DIGITAL device. 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? The short words that used in assembly language are called MNEMONICS. 6. What is the difference between a compiler and an interpreter? 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. 7. What type of software controls the internal operations of the computer’s hardware? An operating system controls the internal operations of the computer’s hardware. Unit 1 Research Assignment 1   * what were the five popular programming languages in each of the following decades: 1970s, 1980s, 1990s, and 2000s?   * Who was the creator...

Words: 483 - Pages: 2

Free Essay

Pt1420

...Using Global Variables Global Variables Global variables are used in applications in programming. There are advantages and disadvantages to using these variables. Using global variables has its advantages in some forms of applications, while using them in others would make using them more difficult. Global variables are useful when you need to share a function with all functions in an application. Global variables can be easier to identify in an application by giving them a unique name, so that other programmers can see they are working with a global variable when maintaining your application. On small programs such as widgets or gadgets it may be easier to use global rather than passing around local variables. Using a global variable means that other functions cannot update it. Another advantage to global is that they can be accessed from anywhere in the program. Some are also disadvantages to using global variables. Global variables can create mutual dependencies, with an increase in dependencies the complexity of the code increases. Any function can access a global variable in the program so a change in the program at one point can change values everywhere. Global variable also slow down performance speed a little. Using global variables makes reusing parts of the script impossible. Global variables also make tracking a bug much harder. When declaring a global variable in a flowchart, you would but the variable in the main part of the program, hence the box the...

Words: 261 - Pages: 2

Free Essay

Pt1420

...Algorithm Workbench Review Questions: Programming Exercise Questions: 1) Personal Information Design a program that displays the following information: · Your name · Your address, with city, state, and ZIP · Your telephone number · Your college major Pseudocode: Display “Enter your name” Input name Display “Enter your address, with city, state, and zip” Input address, city, state, zip Display “Enter your telephone number” Input Telephone number Display “Enter college major” Input college major Input Information Console.Write("Enter your full name: ") name = Console.ReadLine() Console.Write("Enter your address, city, state, and zip: ") addressCityStateZip = Console.ReadLine() Console.Write("Enter your Telephone Number: ") telephoneNumber = Console.ReadLine() Console.Write("Enter your College Degree: ") collegeDegree = Console.ReadLine() Visual Basic Code: Sub Main() 'Declarations for variables Dim name As String Dim addressCityStateZip As String Dim telephoneNumber As String Dim collegeDegree As String 4) Total Purchase A customer in a store is purchasing five items. Design a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 6%. Visual Basic Code: Console.Title = "Total Purchase" Console.WriteLine("Input the...

Words: 290 - Pages: 2

Premium Essay

Pt1420

...In the 1970s the programming language that was most popular was Pascal. Pascal was designed in 1968-69 but published in 1970. Niklaus Wirth created the Pascal language to “a) make available a language suitable for teaching programming as a systematic discipline based on fundamental concepts clearly and naturally reflected by the language, and b) to define a language whose implementations could be both reliable and efficient on then-available computers.” - http://pascal-central.com/ppl/#Origins In 1972 the C programming language was developed by Dennis Ritchie. C was created to work with the system Unix. “Unix gives C such advanced features as dynamic variables, multitasking, interrupt handling, forking, and strong, low-level, input-output. Because of this, C is very commonly used to program operating systems such as Unix, Windows, the MacOS, and Linux.” - http://cs.brown.edu/~adf/programming_languages.html In the 1980s the popular programming language was C++. C++ was developed at Bell Laboratories. “C++ is a general purpose multi-paradigm spanning compiled language that has both high-level and low-level languages’ features. It was started as an enhancement to the C programming language, Bjarne Stroustrup in 1979.” - http://www.freerepublic.com/focus/chat/2880277/posts In the 1990s Java was the popular programming language. It was created in 1991 developed by James Gosling at Sun Microsystems and release in 1995. In the 2000s Visual Basic (VB) was popular in the programming...

Words: 279 - Pages: 2

Premium Essay

Pt1420

...This lab requires you to focus on variable assignment and calculations. Read the following program prior to completing the lab. Write a program that will calculate the cost of installing fiber optic cable at a cost of $0.87 per foot for a company. Your program should display the company name and the total cost. Step 1: Examine the following algorithm as a base for how the program should flow. (Reference: Designing a Program, page 31). 1. Display a welcome message for your program. 2. Get the company name. 3. Get the number of feet of fiber optic to be installed. 4. Multiply the total cost as the number of feet times $0.87. 5. Display the calculated information and company name. Step 2: Think of good variable names for the following pieces of data that will need to be stored with in this program. Purpose of Variable | Variable Name | Stores the cost of fiber | fiberCost | Stores the company name | Companyname | Stores the number of feet to be installed | feetinstalled | Stores the calculated cost of installed fiber | installedcost | Step 3: Complete the following pseudocode based on the algorithm and the variables you declared above. Display “Welcome to the Fiber Optic Calculator Program” Set fiberCost = .87 Display “What is the company name?” Input Companyname Display “How many feet of fiber will be installed?” Input feetinstalled Set 13 Display “For the company”, companyname,”the total cost will be $11.31”,? Now, think...

Words: 429 - Pages: 2

Premium Essay

Pt1420

...Lab 4.1 – Pseudocode and Modules (“UTP Installed”) Critical ReviewA Module is a group of statements that exists within a program for the purpose of performing a specific task.Modules are commonly called procedures, subroutines, subprogram, methods, and functions.The code for a module is known as a module definition. To execute the module, you write a statement that calls it.The format for a module definition is as follows:Module name()StatementStatementEtc.End ModuleCalling a module is normally done from the Main() module such as:Call name()Generally, local variables should be used and arguments should be passed by reference when the value of the variable is changed in the module and needs to be retained. For example:Module main()Real Integer numberCall inputData(number)Call printData(number)End Module// Accepts number as a reference so that changed value// will be retainedModule inputData(Real Ref number)number = 20End Module// number does not need to be sent as reference because// number is not going to be modifiedModule printData(Real number)Display “The number is “, numberEnd Module | This lab requires you to think about the steps that take place in a program by writing pseudocode. Read the following program prior to completing the lab. Data Communications Corp wants a small program that will calculate the cost of UTP it installs for their clients. Write a program that will ask the user to input the name of the client, the number of feet of cable installed. The program...

Words: 1808 - Pages: 8

Premium Essay

Pt1420

...Lab – Configuring Basic Switch Settings Topology Addressing Table Device Interface IP Address Subnet Mask Default Gateway S1 VLAN 99 192.168.1.2 255.255.255.0 192.168.1.1 PC-A NIC 192.168.1.10 255.255.255.0 192.168.1.1 Objectives Part 1: Cable the Network and Verify the Default Switch Configuration Part 2: Configure Basic Network Device Settings  Configure basic switch settings.  Configure the PC IP address. Part 3: Verify and Test Network Connectivity  Display device configuration.  Test end-to-end connectivity with ping.  Test remote management capabilities with Telnet.  Save the switch running configuration file. Part 4: Manage the MAC Address Table  Record the MAC address of the host.  Determine the MAC addresses that the switch has learned.  List the show mac address-table command options.  Set up a static MAC address. Background / Scenario Cisco switches can be configured with a special IP address known as Switched Virtual Interface (SVI). The SVI or management address can be used for remote access to the switch to display or configure settings. If the VLAN 1 SVI is assigned an IP address, by default, all ports in VLAN 1 have access to the SVI management IP address. In this lab, you will build a simple topology using Ethernet LAN cabling and access a Cisco switch using the console and remote access methods. You will examine default switch configurations before configuring basic switch settings. These basic switch settings include...

Words: 4660 - Pages: 19

Free Essay

Pt1420

...Variable Name | Declare String clientName | Declare Real feetUTP | Declare Real subTotal | Declare Real taxCost | Declare Real totalCost | Module Name | Module inputData () | Module calcCosts () | Module displayBill () | Module Main () //Declare local variables 1. Declare String clientName = No Value 2. Declare Real feetUTP = 0 3. Declare Real subTotal = 0 4. Declare Real taxCost = 0 5. Declare Real totalCost = 0 //Module calls 6. Call inputData (feetUTP, clientName) 7. Call calcCosts (feetUTP, subtotal, taxCost, totalCost) 8. Call displayBill (clientName, totalCost) End Module //this module takes in the required user input. There will be a display and input for each variable Module inputData (Real Ref feetUTP, String Ref clientName) 9. Display “Please enter client name:” 10. Input clientName 11. Display “Please enter the amount of UTP (in feet) needed:” 12. Input feetUTP End Module //this module calculates subTotal, taxCost, and totalCost //you also need feetUTP passed in to calculate subTotal Module calcCosts (13. Real feetUTP, Real Ref subTotal, Real Ref taxCost, Real Ref totalCost 14. Set subTotal = feetUTP * .21 15. Set taxCost = subtotal * 0.06 16. Set totalCost = subtotal + taxCost End Module //this module displays clientName and totalCost Module displayBill (17. String clientName, Real totalCost) 18. Display “The order for:”, clientName 19. Display “has a total...

Words: 579 - Pages: 3

Premium Essay

Pt1420 1

...Bradley Griffin Keith Warren PT1420 Unit 2 Assignment 1: Homework Short Answer: 1. If the problem is program assignment of some sort, than the first step would be to design the basis of the program in pseudocode to gain a clear picture of what kind of commands will work where, then move into flowcharting to start putting together the logic. b. If the problem is an issue in the code that is preventing it from executing, than the first thing that should be done is to look over the program for syntax errors and logic errors.  2. Pseudocode is fake code. This is where a programmer writes out the code without worry of syntax or logic errors to get a visual feel of how the program should unfold. 3. Input, Process, and Output 4. User-Friendly is a term used to describe programs that are easy to use. Algorithm Workbench: 1. A. Display “Height” B. Input height C. Display “Here is the height you entered:”, height 2. A. Display “Favorite Color” B. Input Favorite Color C. Display “Here is your favorite color you entered:”, color Programming Exercises: 1. Personal Information 1 Display “Name” 2 Input Name 3 Display “Here is the name you have entered:”, name 4 Display “Address with city, state, and ZIP” 5 Input address with city, state, and ZIP 6 Display “This is the address you have entered:”, address with city, state, and ZIP 7 Display “Telephone number” 8 Input telephone number 9 Display “This is the telephone number you have entered:”, telephone ...

Words: 277 - Pages: 2

Premium Essay

Unit 1 Pt1420

...Unit 1 Research 1 PT1420 In the 1970s the programming language that was most popular was Pascal. Pascal was designed in 1968-69 but published in 1970. Niklaus Wirth created the Pascal language to “1) make available a language suitable for teaching programming as a systematic discipline based on fundamental concepts clearly by the language, and 2) to define a language whose implementations could be both reliable and efficient on then-available computers. In 1972 the C programming language was developed by Dennis Ritchie. C was created to work with the system Unix. “Unix gives C such advanced features as dynamic variables, multitasking, interrupt handling, forking, and strong, low-level, input-output. Because of this, C is very commonly used to program operating systems such as Unix, Windows, the MacOS, and Linux.” In the 1980s the popular programming language was C++. C++ was developed at Bell Laboratories. C++ is a general purpose multi-paradigm spanning compiled language that has both high-level and low-level languages’ features. It was started as an enhancement to the C programming language, Bjarne Stroustrup in 1979. In the 1990s Java was the popular programming language. It was created in 1991 developed by James Gosling at Sun Microsystems and release in 1995. In the 2000s Visual Basic (VB) was popular in the programming world. VB was developed from BASIC which was originally developed in 1964 by John Kemeny and Thomas Kurts. VB is a Microsoft programing language and software...

Words: 261 - Pages: 2

Premium Essay

Pt1420 Unit8

...Unit 8 Assignment 1: Homework Short Answer Review Questions 6-10 6. What is an infinite loop? Write the code for an infinite loop. An infinite loop (or endless loop) is a sequence of instructions in a computer program which loops endlessly, either due to the loop having no terminating condition, having one that can never be met, or one that causes the loop to start over. while (true) { // do stuff } to break it: while (true) { if (condition) break; } OR Set k = 1 While k < = 5 Display k End While 7. A For loop looks like what other loop in a flowchart? A For loop looks like a count-controlled loop. 8. Why is it critical that accumulator variables are properly initialized? An accumulator is used to keep a running total of numbers. In a loop, a value is usually added to the current value of the accumulator. 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 Review Questions 3, 4, 9, 10 3. Design a For loop that displays the following set...

Words: 665 - Pages: 3

Free Essay

Pt1420 Assignment9

...Assignment 9 1. A function is a module that sends a value back to the part that it was called. A module a part of a program that does a specific task. 2. Set result = half (number) Function Integer half(integer number) Declare integer num Input num number = num /2 return number End function 3. Set results = cube(4) 4. Module Module1 Sub Main() Dim testscore As Integer Dim total As Integer = 0 Dim Avg As Double Dim grade As String = "No Value" For index = 1 To 5 Console.Write("Enter test score of " & index & ": ") testscore = Console.ReadLine() While testscore < 0 Or testscore > 100 Console.WriteLine("Enter a valid testscore.") Console.Write("Enter test score of " & index & ": ") testscore = Console.ReadLine() End While total = total + testscore grade = determineGrade(testscore, grade) displaygrades(testscore, grade) Next Avg = calcAverage(total, Avg) displayAverage(Avg) Console.ReadLine() End Sub Function calcAverage(ByVal total As Integer, ByVal Avg As Double) Avg = total / 5 Return Avg End Function Function determineGrade(ByVal testscore, ByVal grade) If testscore < 60 Then grade = "F" ElseIf testscore <...

Words: 484 - Pages: 2