MIDTERM CIS 1101

profileTracyL0101
cis.pdf

CIS 1101 Midterm Examination Dr. Kendall E. Martin Directions: Complete all questions. Point values are listed next to each. You may use your one sheet of crib notes and the Visual Logic tool. For each VL solution, copy a screen shot of your program into a Word doc. Print that out to submit at the end of the exam period. Question 1. (15 pts) Write a Visual Logic program that prompts the user to enter their age in years. The program should then convert that data into dog years using the well known rule: 1 dog year = 7 human years The program should then print out a message. If the equivalent dog age is greater than 5, print: WOW! As a dog, you’re more than half used up ! You are xxxx dog years old. If the dog age is less than 5 , print: Cool – you are just a pup! Only xxx dog years old. Question 2 (10 pts) Add error checking to the program in question 1. If the user enters an age that is silly ( that is, it can’t be negative and it can’t be greater than 117 ! ), force them to re-enter the age until they give something that is reasonable. Question 3 (15 pts) Write a Visual Logic program that reads from the user a list of five names and towns. After you have read these in, print out both lists side by side but in reverse order so the first pair you will print is the last pair entered. For example, if the user entered: Kendall Lansdale Jordan Red Hook Brett Poughkeepsie Marina Bangladesh Peri New York Then the program will print out :

Peri New York Marina Bangladesh Brett Poughkeepsie Jordan Red Hook Kendall Lansdale Question 4 (10 pts) Describe three things that happen when the INPUT statement from Visual Logic is executed. Question 5 (15 pts) Here is a program written in Visual Basic. Create the same program in Visual Logic. Explain what it does by showing the output for a range of input values. Sub Main() Dim MYSTERY Dim ANSWER Console.Write("Please Enter a Value For mystery:") mystery = Console.ReadLine() answer = (mystery / 6) + 5 If ((answer < 15) and (mystery mod 2 = 0)) Then Console.WriteLine("one message") Else Console.WriteLine("other message") End If Console.WriteLine("") Console.WriteLine("Program Complete... Press <Enter> to close...") Console.ReadLine() End Sub Question 6 (10 pts) Write a Visual Logic program that simulates rolling two dice a thousand times. Count and display how many times you roll a six on only one of the die. Question 7 (10 pts) Write a Visual Logic program that rolls two dice. Count how many times you roll before you find you have rolled double sixes. Display that value. Q u e s t i o n 8 (15 pts) Discuss the steps you would take to teach yourself a new programming language, Python. Extra credit : (10 pts) Think back to question 7. How many rolls does it take before you roll double sixes on two consecutive tosses?