Chocolate Delights Candy Company manufactures several

Chocolate Delights Candy Company manufactures several typesof candy. Design a fl owchart or pseudocode for the following:a. A program that accepts a candy name (for example,“chocolate-covered blueberries”), price per pound, andnumber of pounds sold in the average month, and displaysthe item’s data only if it is a best-selling item. Best-sellingitems are those that sell more than 2000 pounds permonth.Be sure to submit this in proper psuedocode and computer programming code format including all the required sections of psuedocode (housekeeping, main loop, end of job tasks). Present this assignment in a powerpoint flowchart with the computer code written as the sample diagrams (slide 41 example) are in the attached file. The final product should fit on either one or two powerpoint slides, with a similar format to slide 41 of the attached file.The attached Powerpoint explains how to properly write all three sections of psuedocode, which is a requirement of this exercise.This exercise is very simple in reality. The company is asking you to read an existing file containing the candy sales for a month. If a candy sells more than 2000 pounds, you are to print the candy name, price per pound, and pounds sold. It’s just that simple. Because it is a report, you also need a report headings plus column headings. Be sure to follow these requirements explicitly.1. You are to be reading an existing file, therefore there is no “INPUT” command and no “QUIT” value to stop the process.2. In reading an existing file, you must inlcude a DO WHILE NOT EOF command to read all the record in the file. Otherwise we only read the first data record.3. When printing headings, which are necessary in any report so we know what data we are looking at, we put all three fields in one heading line. Everytime a PRINT command is executed, another line is printed, so we would say:Heading2 = “Candy Name Price Per Pound Pounds Sold”Print Heading24. Do not use an ELSE command as there is no action necessary if a data record does not meet the test condition of “if lbssold > 2000”. If it does not test true, we just skip that data record and read the next one.PseudocodeWhy use Pseudocode?•We have two design tools to help layoutour program logic–Flowcharts (pictorial representation)–Pseudocode (textual representation)Parts of Pseudocode•Housekeeping (also called the declarationor definition). This section is where wedeclare our variables, set up ourheaders,etc, and get the first recordString lnameString fnameString accountnoNum accountbalString heading1 = “Low Threshhold Accounts”String heading2 = “First Name Last Name AccountMain Loop•Main loop tasks that repeatedly executewithin the program. These tasks includethe instructions that are executed for everyrecord until you reach the end of the input(eof)Do while not (eof)if accountbal < 100print lname, fname, accountno, accountbalendifget lname, fname, accountno, accountbalEnd of Job Tasks••In this section we would print any footersand end the programStop•ALL three sections of pseudocode arerequiredChapter 5:Making DecisionsProgramming Logic and Design,Third Edition IntroductoryObjectives••After studying Chapter 5, you should beable to:Evaluate Boolean expressions to makecomparisons•Use the logical comparison operators•Understand AND logic•Understand OR logicProgramming Logic and8Objectives (continued)••Use selections within rangesUnderstand precedence when combiningAND and OR selections•Understand the case structure•Use decision tablesProgramming Logic and9•Evaluating BooleanExpressions to MakeThe selection structure (sometimesComparisonscalled a decision structure) is one of thebasic structures of structuredprogrammingProgramming Logic and10•Evaluating BooleanExpressions to MakeA dual-alternative, or binary, selection:Comparisonseach of two possible(continued)has an action associated with–outcomes•This selection structure is also called anif-then-else structure because it fits thestatement:if the answer to the question isyes, thendo somethingelseProgramming Logic and11Evaluating Boolean Expressionsto Make Comparisons (continued)•A single-alternative, or unary, selection–••action is required for only one outcome of the questionA Boolean expression is one thatrepresents only one of two states, usuallyexpressed as true or falseEvery decision you make in a computerprogram involves evaluating a BooleanexpressionProgramming Logic and12Using the Logical ComparisonOperators•Usually, you can compare only values thatare of the same type:––•compare numeric values to other numeric valuescompare character values to other charactersYou can ask every programming questionby using one of only three types ofcomparison operators in a BooleanexpressionProgramming Logic and13Using the Logical ComparisonOperators (continued)•For any two values that are the sametype, you can decide whether:––•The first value is greater than the second value–•The two values are equalThe first value is less than the second valueIn any Boolean expression, the twovalues used can be either variables orconstantsEach programming language supportsProgramming Logic and14its own set of logical comparisonUsing the Logical ComparisonOperators (continued)••Most languages allow you to use thealgebraic signs for greater than (>) andless than (<) to make the correspondingcomparisonsAdditionally, COBOL, which is verysimilar to English, allows you to spellout the comparisons in expressions likedayPastDue is greater than30? or packageWeight is lessProgramming Logic and15than maximumWeightAllowed?Using the Logical ComparisonOperators (continued)••Most programming languages alsoprovide for three additional comparisonsFor any two values that are the sametype, you can decide whether:––The first is less than or equal to the second.–•The first is greater than or equal to the second.The two are not equal.Any logical situation can be expressed using just threetypes of comparisons: equal, greater than, and less thanProgramming Logic and16Using the Logical ComparisonOperators (continued)••Comparing two amounts to decide ifthey are not equal to each other is themost confusing of all the comparisonsUsing “not equal to” in decisionsinvolves thinking in double negatives,which makes you prone to includelogical errors in your programProgramming Logic and17Using the Logical ComparisonOperators (continued)Programming Logic and18•Using the Logical ComparisonOperators (continued)Besides being awkward to use, the “notequal to” comparison operator is the onemost likely to be different in variousprogramming languages–––COBOL allows you to write “not equal to”Pascal uses a less-than sign followed immediately by agreater-than sign (<>)C#, C++, C and Java use an exclamation point followedby an equal sign (!=)Programming Logic and19Understanding AND Logic•••Often, you need more than oneselection structure to determine whetheran action should take placeFor example, suppose that youremployer wants a report that listsworkers who have registered for bothinsurance plans offered by thecompany: the medical plan and thedental planKnown as an AND decision becauseProgramming Logic and20Understanding AND Logic(continued)•Acompound,or AND,decisionrequires anesteddecision, ora nested if—that is, adecisionProgramming Logic and21Writing Nested AND Decisionsfor Efficiency•••When you nest decisions because theresulting action requires that twoconditions be true, you must decidewhich of the two decisions to make firstLogically, either selection in an ANDdecision can come firstHowever, when there are twoselections, you often can improve yourprogram’s performanceand making anbyProgramming Logic22Writing Nested AND Decisionsfor Efficiency (continued)•In many AND decisions, you have no ideawhich of two events is more likely to occur;–•In that case, you can legitimately ask either questionfirstIn addition, even though you know theprobability of each of two conditions, thetwo events might not be mutually exclusive–In other words, one might depend on the otherProgramming Logic and23Combining Decisions in an ANDSelection••Most programming languages allow you toask two or more questions in a singlecomparison by using a logical ANDoperatorIf the programming language you useallows an AND operator, you still mustrealize that––the question you place first is the question that will beasked firstcases that are eliminated based on the first question willProgramming Logic and24Combining Decisions in anAND Selection (continued)•The computer can ask only onequestion at a timeProgramming Logic and25Combining Decisions in an ANDSelection (continued)Programming Logic and26Avoiding Common Errors in anAND Selection••When you must satisfy two or more criteriato initiate an event in a program, you mustmake sure that the second decision ismade entirely within the first decisionBeginning programmers often makeanother type of error when they mustmake two comparisons on the same fieldwhile using a logical AND operatorProgramming Logic and27Understanding OR Logic••Sometimes, you want to take actionwhen one or the other of two conditionsis trueCalled an OR decision because––•either one condition must be met orsome other condition must be met, in order for anevent to take placeIf someone asks you, “Are you freeFriday or Saturday?,” only one of thetwo conditions has to be true in orderfor the answer to the whole question toProgramming Logic and28be “yes”Understanding OR Logic(continued)Programming Logic and29•Incorrect Flowchart formainLoop()This flowchart is not allowed because itis not structuredProgramming Logic and30Avoiding Common Errors in anOR Selection••An additional source of error that isspecific to the OR selection stems from aproblem with languageThe way we casually use English cancause an error when a decision based ona value falling within a range of values isrequiredProgramming Logic and31Writing OR Decisions forEfficiency•You can write a program that creates areport containing all employees who haveeither the medical or dental insurance byusing the mainLoop()Programming Logic and32Writing OR Decisions forEfficiency (continued)Programming Logic and33Writing OR Decisions forEfficiency (continued)Programming Logic and34Writing OR Decisions forEfficiency (continued)•••One of these selections is superior to theotherUsing either scenario, 950 employeerecords appear on the list, but the logicused in Figure 5-26 requires 1,100decisions, whereas the logic used inFigure 5-27 requires 1,500 decisionsThe general rule is: In an OR decision,Programming35first ask the question Logic and more likely tothat isCombining Decisions in an ORSelection••If you need to take action when either oneor the other of two conditions is met, youcan use two separate, nested selectionstructures, as in the previous examplesHowever, most programming languagesallow you to ask two or more questions ina single comparison by using a logical ORoperatorProgramming Logic and36Using Selections Within Ranges•••Business programs often need to makeselections based on a variable fallingwithin a range of valuesWhen you use a range check, youcompare a variable to a series of valuesbetween limitsTo perform a range check, makecomparisons using either the lowest orProgramming Logic and37highest value in each range of values youCommon Errors Using RangeChecks•••Two common errors that occur whenprogrammers perform range checks bothentail doing more work than is necessaryFigure 5-33 shows a range check in whichthe programmer has asked one questiontoo manyAnother error that programmers makewhen writing the logic to perform a rangecheck involves asking unnecessaryProgramming Logic and38Inefficient Range SelectionIncluding Unreachable PathProgramming Logic and39•Understanding PrecedenceWhen Combining AND andMost programming languages allow youOR Selectionsto combine as many AND and ORoperators in an expression as needed•••The logic becomes more complicatedwhen you combine AND and ORoperators within the same statementWhen you combine AND and ORoperators, the AND operators takeprecedence, meaning their Booleanvalues are evaluated firstProgramming Logic and40You can avoid the confusion of mixing•Understanding the CaseStructureThe Logic below is completelystructuredProgramming Logic and41•••Understanding the CaseStructure (continued)Writing the logic using a case structure,as shown in Figure 5-37, might make iteasier to understandThe case structure provides aconvenient alternative to using a seriesof decisions when you must makechoices based on the value stored in asingle variableWhen usingProgramming Logic andthe case structure,42you testFlowchart and Pseudocode ofHousing Model Using the CaseStructureProgramming Logic and43Using Decision Tables•A decision table is a problem-analysistool that consists of four parts:––––ConditionsPossible combinations of Boolean values for theconditionsPossible actions based on the conditionsThe specific action that corresponds to eachBoolean value of each conditionProgramming Logic and44Summary••Every decision you make in a computerprogram involves evaluating a BooleanexpressionFor any two values that are the sametype, you can use logical comparisonoperators to decide whether–the two values are equal,–the first value is greater than the second value, or–the first value is less than the second valueProgramming Logic and45Summary (continued)••Most programming languages allow youto ask two or more questions in a singlecomparison by using a logical ANDoperatorAn OR decision occurs when you wantto take action when one or the other oftwo conditions is trueProgramming Logic and46Summary (continued)••Most programming languages allow youto ask two or more questions in a singlecomparison by using a logical ORoperatorThe case structure provides aconvenient alternative to using a seriesof decisions when you must makechoices based on the value stored in asingle variableProgramming Logic and47



We pride ourselves in writing quality essays


Lets Start Working

Plagiarism Free

We use anti-plagiarism software to ensure you get high-quality, unique papers. Besides, our writers have a zero plagiarism mentality

On Time Delivery

Your essay will be delivered strictly within the deadline.  If you have an urgent order, we can do it!

Money Back Guarantee

We offer warranty service, including free revisions, and a right to request a refund incase your expectations are not met!


Our Advantage

  • Say “NO” to plagiarism – FREE plagiarism report as an addition to your paper
  • The lowest prices that fit excellent quality
  • Authorship – you are the one who possesses the paper. We DO NOT re-sale or re-use any of them.


Our Freebies

  • Free Cover Page
  • Free Revisions
  • Free Reference Page
  • Free 24/7 support

Pin It on Pinterest

Share This