Unit 8 Assignments and Research

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Chris trimble

Unit 8 Assignment and Research


Short Answers:
6. Its a sequence of instructions in a computer program which loops endlessly
Dim InfiniteLoop as Boolean = true;
For a = 1 to 45687999
If a = 45687999 And InfiniteLoop = true Then a = 1
End For
7. A while loop
8. So it doesnt contain garbage
9. Because the list is long of numbers and it will mark the end of the lists automatically
10. so that it will not be mistaken for a regular value or values in the list

Algorithm Workbench
3.
for I = 0 to 1000 step 10
Print i
4.
Declare Integer product
Declare Integer number
Product = 0
Do While product < 100
Display Enter a number
Input Number
Product = product + number * 10
Loop

Chris trimble

Display Product
9.
Declare Integer count
For(count = 0; count <50; count ++)
Display The count is, count
10.
Declare Integer count
Count = 1
While count <= 50
Display count
Count = count + 1
End While

Programming Exercises
7.
Module main()
Local variables
Declare Realnumber of years, RealTotal rainfall
Get number of years, total rainfall
Call getNumber of years(number 0f years, total rainfall)
Calculate the number of years, total rainfall
Callset total(number of years, total rainfall
Call show total(number of years, total rainfall)
End Module
Module getNumber(Real Ref Input number of years)

Chris trimble

Display Enter the number of years:


Input Number of years
End Module
Module setNNumber(Real years, months)
Declare Integer counter number of years, months
For counter every year <= number of year
For counter every month <= 12
Display Please enter the rainfall in inches
Input number of inches
Set RealTotal rainfall = RealTotal rainfall + number of inches
End For
End For
Module showTotal number of months, total rainfall, total average
Number of months = numbers of years * 12
Display Number of months: $, number of months
Display Total rainfall: $, total rainfall
Display Average rainfall:$, total rainfall/number of months
9.
Main
Variables
Declare Integer numDays = 1
Declare Integer daysWorked = 0
Declare Integer dailyPayInDecimal = .02
Declare Integer totalPayInDecimal = 0
Explain what this program does

Chris trimble

Display This program calculates the amount of money


Display a person would earn over a period of time
Display if the salary is one penny for the 1st day,
Display two pennies the 2nd and continues to double each day1
Display Enter the number of days worked:
Input daysWorked
Display Days Worked, Tab, Pay Each Day
Display
Calculate salary
While numDays, Tab, $dailyPayInDecimal
Set dailyPayInDecimal = dailyPayInDecimal * 2
Set totalPayInDecimal = dailyPayInDecimal + totalPayInDecimal
End While
Display results in a table
Display The total expenses for the month is: ,Tab, $,totalPayInDecimal
End Main
10.
Module Main()
//declare variables
Declare Integer number = 0
Declare Integer highNumber = 0
Declare Integer lowNumber = 0
//Display what the program does
Display This program asks the user to enter a series of numbers

Chris trimble

Display when finished, enter -99 to display the highest and lowest number
entered.
//Get input
If number ! = -99 Then
Display Enter your number:
Input number
If number > highNumber Then
highNumber = number
Else lowNumber = number
End If
Display The high number is: , highNumber
Display The low number is: , lowNumber
Display Thank you for your time!
End Main

Research
Count Controlledone set variable to an initial value, Two a test must be done
before entering the loop, Three the variable must also be incremented each time the
loop body is executed.
Condition Controlled Loopsthe loop is controlled by a specific condition. The
loop will continue to run as long as the condition is fulfilled. So it uses a true/false
condition to control the number of times that it will repeat.

You might also like