1. What does a professional programmer usually do first to gain an understanding of a problem?
Work directly with the customer.
2. What is pseudocode?
Fake code as known as an informal language that has no syntax rules, and is not meant to be compiled or executed.
3. Computer programs typically perform what three steps?
Input, process, and output.
Chapter 2: Algorithm Workbench 1-2
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.
Display “What is your height?”
Input height
2. Design an algorithm that prompts the user to enter his or her favorite color and stores the user’s input in a variable named color.
Display “What is your favorite color?”
Input Color
Chapter 2: Programming Exercises 1, 4
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
Flowchart: Visual Basic Code:
Sub Main() 'Declarations for variables Dim name As String Dim addressCityStateZip As String Dim telephoneNumber As String Dim collegeDegree As String
'Input Imformation 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()
'Displaying personal Information Console.Write("Your name is: " & name & "," & " your address is: " & addressCityStateZip & "," & " your telephone number is: " & telephoneNumber & ", and" & " your college degree is: " & collegeDegree & ".") Console.ReadLine() End Sub
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 percent.
Purpose: To calculate the total amount of a purchase.
Input:
• Cost of items
• Subtotal of the sale
• Amount of sale tax 6%
• Total price
Process:
• Subtotal
• Sale tax = 6%
• Total price
Output:
• Display subtotal
• Display sale tax = 6%
• Display Total price
Pseudocode:
Display “cost of item1”
Input price
Display “cost of item2”
Input price
Display “cost of item3”
Input price
Display “cost of item4”
Input price
Display “cost of item5”
Input price
Display “Subtotal”
Subtotal = item1 + item2 + item3 + item4 + item5
Set Tax = subtotal * 0.06
Set TotalCost = subtotal + Tax
Display “Subtotal, Tax, and TotalCost
Flowchart:
Visual Basic Code:
Sub Main() 'Declarations for variables Dim costItem1 As Double Dim costItem2 As Double Dim costItem3 As Double Dim costItem4 As Double Dim costItem5 As Double Dim subtotal As Double Dim tax As Double Dim totalCost As Double
'Request for price Console.Write("Enter Price: ") costItem1 = Console.ReadLine() Console.Write("Enter Price: ") costItem2 = Console.ReadLine() Console.Write("Enter Price: ") costItem3 = Console.ReadLine() Console.Write("Enter Price: ") costItem4 = Console.ReadLine() Console.Write("Enter Price: ") costItem5 = Console.ReadLine()
'Calculations for subtotal subtotal = costItem1 + costItem2 + costItem3 + costItem4 + costItem5 tax = subtotal * 0.06 totalCost = subtotal + tax
'Total for customer Console.Write("Your Subtotal was: " & subtotal & "." & " Your Tax was: " & tax & "." & " Your purchase amount is: " & totalCost & ".") Console.ReadLine() End Sub
You May Also Find These Documents Helpful
-
Step 1: Examine the following algorithm as a base for how the program should flow. (Reference: Designing a Program, page 31).…
- 777 Words
- 4 Pages
Satisfactory Essays -
The objective was to create a program using python. The program should successfully ask the user to input his or her name. Then ask the user to enter his or her age. If they are older than 16 then they can drive a car. Display this message along with their name. Then end the program by stating the users name, and that it is nice to meet them.…
- 320 Words
- 2 Pages
Satisfactory Essays -
2.Write a program to (a) display a “?” (b) read two decimal digits whose sum less than 10 (c) display them and their sum on the next line. Page: 80…
- 582 Words
- 3 Pages
Satisfactory Essays -
1. What does a professional programmer usually do first to gain an understanding of a problem?…
- 320 Words
- 3 Pages
Satisfactory Essays -
1) What does a professional programmer usually do first to gain an understanding of a problem?…
- 307 Words
- 2 Pages
Satisfactory Essays -
1. What does a professional programmer usually do first to gain an understanding of a problem?…
- 848 Words
- 4 Pages
Satisfactory Essays -
4. Design a loop that asks the user to enter a number. The loop should iterate 10 times and keep a running total of the numbers entered.…
- 793 Words
- 5 Pages
Good Essays -
3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report each output.…
- 662 Words
- 3 Pages
Satisfactory Essays -
What is an informal language that has no syntax rules and is not meant to be compiled or executed? Pseudo Code…
- 738 Words
- 3 Pages
Good Essays -
You can even create interactive programs that allow the user to input values for variables…
- 5177 Words
- 21 Pages
Good Essays -
Extract the First and Last Name, Address, City, State, Zip Code and Phone Number of each senior on the database. Sort by Last Name, then First Name (1 sort).…
- 325 Words
- 2 Pages
Satisfactory Essays -
____ data items may involve organizing or sorting them, checking them for accuracy, or performing calculations with them.…
- 2450 Words
- 10 Pages
Satisfactory Essays -
Printer Qualities: Resolution � dpi; Print Speed (and memory); Cost to Purchase; Cost to Run (cost per page; monthly pages & maintenance)…
- 648 Words
- 3 Pages
Satisfactory Essays -
| Allows users to organize data in rows and columns and perform calculations and recalculate when data changes.…
- 609 Words
- 3 Pages
Good Essays -
16.You are examining your addresses file, which contains the first and last names of people you know as well as their street address, city, state, zip code, and telephone number. You want to print a list of last names, which is field 1, and telephone numbers, which is field 7. Which of the following commands enables you to print this list?Answer: c. cut -f1,7 addresses…
- 1020 Words
- 5 Pages
Satisfactory Essays