ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 27 Apr 2017 My Price 9.00

lane at a grocery store

Good programmers are able to analyze a task and describe it succinctly, accurately, and unambiguously. Even tasks that you perform without much thought are surprisingly complex when you stop and consider all of their components. For example, using the self-checkout lane at a grocery store—a simple task completed by thousands of people every day—requires you to: (1) Select items in your basket; (2) Scan the UPC codes; (3) Convey the item to the bagging area; (4) Bag your groceries; and (5) Submit payment for your purchases.

A program is an ordered list of instructions that prepares the computer (or in the case of the grocery example, the shopper and new user of the self-checkout lane) to complete a task. Good instructions are mindful of the target audience, and the less you assume the reader already knows about a process, the more useful the instructions are to a wider audience.

If you have not used the self-checkout lane at a grocery store before, you act as your own cashier. You scan and weigh your items, bag them, and pay for them, while being guided by a digitized voice prompting you to complete each step.

Consider the pseudo code in the "Week 1 Discussion Code" text  file (located in this week's Learning Resources) that describes the self-checkout procedure. While it is comprehensive, it is also organized. It groups instructions related to the same task into a block of text, and adds comments and explanations using specific conventions:

  • Actions defined by a group of steps have descriptive names, includingSelectItem,ScanBarCode, andPayingWithCredit.
  • Blocks of instruction are contained within braces:{and}.
  • // means that the rest of the line is a comment Intended for people, not an instruction to the computer.
  • When /* is used at the beginning of a line, it signifies that the entire line is a comment and will be ignored by the computer.
  • The symbols /** and */ start and end comments that extend over multiple lines. These are used to describe processes within your program.

Note: You will investigate this notation further in Week 2.

The code in the "Week 1 Discussion Code" text file (located in this week’s Learning Resources) includes line numbers along the left side of the page. These are not part of the program but they make it easy to refer to specific commands and instructions within the program.

Think about one task you perform so often, it is nearly automatic. Break that task down into its component parts and write a "program" that resembles the grocery self-checkout code provided to describe your task. Your task should include:

  • At least threemajor steps, listed in chronological order
  • Specific instructions that describe each step
  • Conditions that direct the flow of the program, such as "if-then," "while," or "until."
  • Comments that explain your program
  • Line numbers

By Day 3, post your program and read some of the programs posted by other colleagues. Identify steps in their programs that could be further developed to make the program unambiguous to as wide an audience as possible.

By Day 6, respond to at least two other colleagues' posts. Your responses should:

  • Identify a step or instruction in the program that could be further expanded or explained.
  • Explain why you think more detailed instructions would be valuable.
  • Write 5–10 lines of pseudo code that could be inserted into, or appended to the end of, the program to provide the additional instructions.

Remember, you are not identifying errors in someone else's program. This exercise cannot contain errors of syntax, as pseudo code does not have established rules of use or standard language. However, instructions that seem erroneous or unclear are prime candidates for clarification. Respond positively and constructively to others' work. The goal is to learn from one another in an encouraging manner.

1/**
2   *  How to use a self-checkout lane at a grocery store
3   *  By Your Name, 06/06/2011
4   *
5   *  Assumes you have a shopping cart full of groceries
6   *  and no help scanning or bagging unless you specifically
7   *  summon an employee for assistance.
8   */
9
10  StepOne SelectItem        //Grab an item from cart or basket
11{
12Question: Are there any items left to be scanned?
13/* Checks to see if you're all done scanning
14If the answer is no, move to StepFive
15
16Pick up item to be scanned
17  }
18
19StepTwo ScanBarCode //Ring up the item from StepOne
20{
21Until you can locate the bar code,
22Keep rotating the item along the x-, y-, and z-axes
23/* Spin it every which way. Where is that UPC code?
24
25Question: Did you find the bar code yet?
26If no, answer this question: Have 15 seconds elapsed?
27
28If no, then keep looking for the bar code
29Otherwise, start SkuLookup //Treat it like produce
30{
31Place item on the scale
32Find item in the SKU lookup book at register
33Question: Is the SKU number in the book?
34
35If yes, then InputSkuNumber
36{
37Input the SKU number
38Wait for the item to be priced
39Remove the item from the scale
40Go to StepThree
41}
42Otherwise, press 'Call attendant' help button
43/** 
44  * Assumes items with no bar code can be identified
45  * in a lookup database present at machine.
46  */
47}
48
49Until you hear a confirmation tone,
50Hold the bar code over the scanner,
51Rotating the item slightly
52}
53
54StepThree ConveyToBagging //Assumes there is a conveyer belt
55{
56Place item on conveyor belt
57Wait until item travels down entire conveyor belt
58/* Computer compares item on belt to expected height/weight
59
60Question: Is the computer asking you to rescan item?
61If yes, then return to StepTwo
62Otherwise, continue
63
64Question: Is the bagging area full?
65If yes, then go to StepFour
66Otherwise, go to StepOne
67}
68
69StepFour BagGroceries // No room to scan new items
70{
71Question: Did you bring your own shopping bags?
72If yes, then use the bags you brought.
73Otherwise, answer this question:
74
75Do you have to buy empty bags at this store?
76If yes, then purchase bags for scanned items
77Otherwise, place items into bags provided
78
79Group refrigerated and frozen items together when possible
80Place heavier items below lighter items
81
82Question: Have you completed StepFive?
83If yes, then the checkout process is complete
84Otherwise, go to StepOne
85
86/**
87   * This step assumes the user has some prior experience
88  * bagging groceries. More detail could be added.
89  */
90}
91
92StepFive SubmitPayment // No items left to scan
93{
94Press the 'Finished scanning items' button
95
96Question: Are you paying with cash?
97If yes, then begin PayingWithCash
98{
99Insert appropriate number of bills
100Insert coins, if desired
101Press 'Finished inserting cash'
102Check coin/bill return area for change
103}
104Question: Are you paying with a debit or credit card?
105If yes, then begin PayingWithCredit
106{
107Swipe card through card reader
108If a debit card, enter your PIN when prompted
109If prompted for a signature, use stylus to sign
110}
111/* Assumes not paying by check. Who does that anymore?
112
113Collect receipts and all paperwork
114Question: Are any groceries left unbagged?
115If yes, go to StepFour
116}

Answers

(11)
Status NEW Posted 27 Apr 2017 08:04 AM My Price 9.00

-----------

Not Rated(0)