Unit 4 Programming Essay

1029 words - 5 pages

Unit 4

Short Answers 1-7
1. How do modules help you to reuse code in a program?
A. It reduces the duplication of code within a program by reusing the module that was written once.
2. Name and describe the two parts that a module definition has in most languages.
A. Header and a body, header indicates starting point, and the body is a list of statements.
3. When a module is executing, what happens when the end of the module is reached?
A. It’s executed and returned back to the point in main program where it was sidetracked from.
4. What is a local variable? What statement is able to access a local variable?
A. A variable declared inside a local module, only ...view middle of the document...

4
Display x, “ “, y
Call changeUs (x, y)
Display x, “ “,y
End module
6. What will the following pseudocode program display?
Module changeUs (Integer a, Real b)
Set a = 0
Set b = 0
Display a, “ “, b
End Module
It will not display anything since nothing within the “ “ .
7. What will the following pseudocode program display?
Module main ( )
Declare Integer x =1
Declare Real y = 3.4
Display x, “ “, y
Call changeUs (x, y)
Display x, “ “, y
End Module
Module changeUs (Integer Ref a, Real Ref b)
Set a = 0
Set b = 0.0
Display a, “ “, b
End Module
You would think it displays but in both modules both strings within the quotations marks are blank to display.
Programming Exercises 1, 2
1. Design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. The conversion formula is as follows:
Miles = Kilometers x 0.6214
Module main()
Declare real kilometers
Display “Enter a distance in kilometers”
Input kilometers
Call conversion(kilometers)
End Module
Module conversion(real value)
Declare real miles
Set miles = value * 0.6214
Display miles
End Module
2. Sales Tax Program Refactoring
Programming Exercise 6 in Chapter 2 was the Sales Tax program. For that exercise you were asked to design a program that calculates and displays the county and state sales tax on a purchase. If you have already designed that program, refactor it so the subtasks are in modules. If you have not already designed that program create a modular design for it.
Module main()
Declare real purchase
Display “Enter the amount of purchase.”
Input purchase
Call Module totalState(purchase)
Call Module totalCounty(purchase)
Declare real totalTax
Declare real totalSale
Set totalTax = totalState + totalCounty
Set totalSale = purchase + totalTax
Display “Your amount of purchase is “, purchase
Display “Your total state tax is “, totalState
Display ”Your total county tax is “, totalCounty
Display “Your total tax is “, totalTax
Display “Your total of your sale is “, totalSale
End Module
Module totalState (real Ref purchase)
Set totalState...

Other assignments on Unit 4 Programming

The It Guy Essay

290 words - 2 pages Francisco gonzalez IT104 Unit 2 Assignment 1 Short Answer   1. What does a professional programmer usually do first to gain an understanding of a problem?       a. A professional programmer gains this understanding by working directly with the customer.    2. What is pseudocode?       b. Pseudocode is a fake code. It is an informal language that has no syntax rules, and is not meant to be compiled or executed.   3. Computer programs

Yeah Essay

1019 words - 5 pages Computer and its components Computer : Computer itself a combination of different type of separate electronic device. i.e. Computer only will be computer if it has INPUT DEVICE, PROCESS UNIT, and OUTPUT DEVICE. Central Processing Unit (CPU) : It is heart and mind of the computer without this unit computer unable to process. Keyboard : This is an input device which is used to input the data into the computer. Mouse : This is also an

Om White Psper

1312 words - 6 pages Line Balancing Group Members Sr. No. | Member Name | PRN | 1 | Bhushan Daga | 15020841130 | 2 | Kanika Gulati | 15020841176 | 3 | Parantak Soni | 15020841147 | 4 | Priyank Singhvi | 15020841150 | 5 | Ridhi Choudhary | 15020841154 | 6 | Snehil Bhadkamkar | 15020841162 | Introduction Production capacity required for production lines is determined by Product Design and the market demand. Once the production capacity is

Inexperienced Leadership

3303 words - 14 pages . Actively oversees and manages proper implementation of unit programs for supply and the issue of all mobility bag assets d. Administers procedures, programming and staffing of individuals, supplies and parts for A-10 and KC-135 Aircrafts. The inability of the higher command to provide a stable environment of a strong leadership perpetuates the fundamental weaknesses within the current Logistics Readiness Squadron. Over the past 3

Soley

2369 words - 10 pages happen AL = 80h CF = 0; there is no carry out of bit 7 PF = 0; 80h has an odd number of ones AF = 1; there is a carry out of bit 3 into bit 4 ZF = 0; the result is not zero SF = 1; bit seven is one OF = 1; the sign bit has changed 15 * 16. BUS INTERFACE UNIT (BIU)Contains• 6-byte Instruction Queue (Q)• The Segment Registers (CS, DS, ES, SS).• The Instruction Pointer (IP).• The Address Summing block (Σ) 16 * 17. THE QUEUE (Q)• The BIU uses a

Unit 4 Btec Extended Certificate

1628 words - 7 pages Btec National Extended Diploma Sport Unit 4 Fitness Training & Programming Unit 7 Fitness Testing for Sport & Exercise Science [pic] Student Name: Callum Mcvay |P1 | Scenario Fitness is vital to achieving success in sport, and testing plays a valuable role in the

Unknown

5042 words - 21 pages : ca14h 5.3-1 Diff: 1 Terms: activity-based costing (ABC) Objective: 3 16) B ID: ca14h 5.4-1 Diff: 1 Terms: output unit-level costs Objective: 4 17) C ID: ca14h 5.4-2 Diff: 1 Terms: batch-level costs Objective: 4 18) A ID: ca14h 5.4-8 Diff: 2 Terms: output unit-level costs Objective: 4 19) D ID: ca14h 5.8-1 Diff: 2 Terms: activity-based costing (ABC) Objective: 8 20) C ID: ca14h 6.1-7 Diff: 2 Terms: master budget Objective: 1

Evolution Of Computers

9431 words - 38 pages modern computer such as input/output, storage, processor and control unit. 3.10 Hollerith's Tabulator Herman Hollerith invented the punched-card tabulating machine to process the data collected in the United States' census. This electronic machine was able to read the information on the cards and process it electronically. It consisted of a tabulator, a sorter with compartments electronically controlled by the tabulator's counter and a device

Tone Acivated Robot

4350 words - 18 pages embedded systems (like a microcontroller). It allows for such software to be written either in assembly or C programming languages and for that software to be simulated on a computer before being loaded onto the microcontroller. 2.5 CONCLUSION Thus the generation of the block diagram and its description has been dealt in this chapter using hardware and its implementation using software. CHAPTER 3 3.1 DESCRIPTION OF AT89S52 Looking

Software Testing Myths

1551 words - 7 pages issues will, in many cases, backfire first to the testing teams. The very first question asked: “Why was this scenario not covered in the test plan??” Therefore, a Tester should develop the capability to look or think Beyond the Requirements mentioned in the test plan or specifications. This is very important in case of System Testers who are responsible for ensuring that the software product works appropriately from "end-to-end ". 4. Testing does

Dsc340

2104 words - 9 pages 1 Byte = 8 Bits 1 KB = 8,192 Bits 1 kB = 1,024 Bytes 1MB =1024 KB 1GB = 1024 MB 1TB = 1024 GB 1PB = 1024 TB 1EB = 1024 PB 1ZB = 1024 EB Blu-ray disc: 25-50 GB Feature DVD movie: 4-7 GB Digital picture

Similar Documents

Managing Pricing Decisions Essay

443 words - 2 pages takes 4 hours of labor per unit and Product Y takes 2 hours of labor per unit. The total machine hours available are 750 hours per week. Product X takes 1 machine hour per unit and Product Y takes 5 machine hours per unit. a. Formulate the linear programming constraints and the objective functions for this problem. b. Draw the graph for this linear programming problem. c. Provide solution for the best combination of product X and Y, and show the maximum profit for this problem.  Answer: Objective function: Maximize Z = $100 X + $80 Y Subject to: 4 X + 2 Y ≤ 800 X + 5 Y ≤ 750 Solution: X = 138.89 Y = 122.22 Z = $23,666.67

Pt1420 V1 Unit 2 Assignment 1: Homework

319 words - 2 pages 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

Program Essay

291 words - 2 pages Siegfried Williams Unite 2 home work UNIT 2 HOME WORK SHORT ANSWER 1. What does a professional programmer usually do first to gain an understanding of a problem? .Break the larger problem into independent sub-problems 2. What is pseudocode? Pseudocode is a detailed yet readable description of what a computer program or algorithm must do, and is expressed in a formally-styled natural language rather than in a programming language. 3

Goal Programming Essay

1181 words - 5 pages .  We use soft constraints to represent such goals or targets we’d like to achieve. A Goal Programming Example: Myrtle Beach Hotel Expansion  Davis McKeown wants to expand the convention center at his hotel in Myrtle Beach, SC.  The types of conference rooms being considered are: Size (sq ft) Unit Cost Small Medium Large  400 750 1,050 $18,000 $33,000 $45,150  Davis would like to add 5 small, 10 medium and 15