Preview

Chapter 6 solutions

Good Essays
Open Document
Open Document
4145 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Chapter 6 solutions
Programming Logic and Design, 6e

Solutions 6-1

Programming Logic and Design, 6th Edition
Chapter 6
Exercises
1.

a. Design the logic for a program that allows a user to enter 10 numbers, then displays them in the reverse order of their entry.

Answer:
A sample solution follows
Flowchart:

Pseudocode: start Declarations num index num SIZE = 10 num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0 getReady() Programming Logic and Design, 6e

Solutions 6-2

while index < SIZE getNumbers() endwhile finishUp() stop getReady() index = 0 return getNumbers() output “Enter a number for position ”, index input numbers[index] index = index + 1 return finishUp() output “The numbers in reverse order are: ” while index > 0 index = index – 1 output numbers[index] endwhile return

b. Modify the reverse-display program so that the user can enter up to 10 numbers until a sentinel value is entered.
Answer:
A sample solution follows
Flowchart:

Programming Logic and Design, 6e

Pseudocode: start Declarations num index num SIZE = 10 num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0 string CONTINUE = “Y” string moreNumbers = CONTINUE getReady() while index < SIZE AND moreNumbers equal to CONTINUE getNumbers() endwhile finishUp() stop getReady() index = 0 output “Do you want to enter a number? (Y/N)” input moreNumbers return getNumbers() output “Enter a number for position ”, index input numbers[index] index = index + 1

Solutions 6-3

Programming Logic and Design, 6e

Solutions 6-4

output “Do you want to enter more numbers? (Y/N)” input moreNumbers return finishUp() output “The numbers in reverse order are: ” while index > 0 index = index – 1 output numbers[index] endwhile return

2.

a. Design the logic for a program that allows a user to enter 10 numbers, then displays each and its difference from the numeric average of the numbers.

Answer:
A sample solution follows
Flowchart:

Programming

You May Also Find These Documents Helpful

  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    Design a program that calculates the total amount of meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales tax. Display each of these amounts and the total.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Psychology Assignment

    • 1556 Words
    • 7 Pages

    10. College XYZ wants to collect information from students concerning a plus/minus grading system (the college administration wants to add minus grades to the plus values…

    • 1556 Words
    • 7 Pages
    Good Essays
  • Good Essays

    it320 assignment 1-3

    • 1779 Words
    • 8 Pages

    7. A user has opened a calculator application, typed the numbers 123456789, and then done some math problem using this number. Which of the following determines, in part, what bits the computer (D. the binary equivalent of decimal 123456789)…

    • 1779 Words
    • 8 Pages
    Good Essays
  • Good Essays

    pt1420 exam review

    • 738 Words
    • 3 Pages

    1 - Design the Program2 - Write the Code3 - Correct Syntax Errors4 - Test the Executable Code…

    • 738 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Pt1420 week 2

    • 320 Words
    • 3 Pages

    1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height.…

    • 320 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    2. The program will display a series of screens prompting the user to enter the item name or number, price and quantity.…

    • 498 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a. Should “problem” = 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.…

    • 848 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Nt1210 Chapter 1 Review

    • 1315 Words
    • 6 Pages

    6. A user file has opened a word processor, typed the numbers 123456789, and stored the document as a file called report 1. Which of the following determines, in part what bits the computer stores in the file to represent the text typed into the report.…

    • 1315 Words
    • 6 Pages
    Good Essays
  • Better Essays

    Program Lovecs.Java

    • 422 Words
    • 2 Pages

    import java.util. Scanner; public class LoveCS { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; limit= scan.nextInt(); int sum=0; int count=1; while (count <=limit) { System.out.println(count+" I love Computer Science!!"); sum+=count; count++; } System.out.println("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); } } import java.util. Scanner; public class PowersOf2 { public static void main(String[]args) { int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0; Scanner scan = new Scanner(System.in); System.out.println("Enter A Number.");…

    • 422 Words
    • 2 Pages
    Better Essays
  • Good Essays

    You can even create interactive programs that allow the user to input values for variables…

    • 5177 Words
    • 21 Pages
    Good Essays
  • Satisfactory Essays

    a. The advantages to using reverse engineering is that one can repair certain bugs, see how a program operates and improve the operation of the program…

    • 197 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    Write a program that will take in basic information from a student, including their name and how many credits they have taken in Network Systems Administration program. The program will then calculate how many credits are needed to graduate. Display should include the student name and the number of credits left to graduate. This should be based off a 90 credit program, where some courses are half credits.…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Step 2: Think of good variable names for the following pieces of data that will need to be stored with in this program.…

    • 777 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    Chapter 1: Before you start Chapter 2: Your first program Chapter 3: Variables Chapter 4: Retrieving keyboard input from the user Chapter 5: The IF and THEN commands Chapter 6: Labels and the GOTO and GOSUB commands Chapter 7: Loops Chapter 8: What next?…

    • 1751 Words
    • 8 Pages
    Powerful Essays