23.05.2017 Views

COMP 122 DeVry Week 3 iLab 3 Latest

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>COMP</strong> <strong>122</strong> <strong>DeVry</strong> <strong>Week</strong> 3 <strong>iLab</strong> 3 latest<br />

Downloading is very simple, you can download this Course here:<br />

http://mindsblow.us/question_des/<strong>COMP</strong><strong>122</strong><strong>DeVry</strong><strong>Week</strong>3<strong>iLab</strong>3<strong>Latest</strong>/4618<br />

Or<br />

Contact us at:<br />

help@mindblows.us<br />

<strong>COMP</strong> <strong>122</strong> <strong>DeVry</strong> <strong>Week</strong> 3 <strong>iLab</strong> 3 <strong>Latest</strong><br />

<strong>COMP</strong><strong>122</strong><br />

<strong>COMP</strong> <strong>122</strong> <strong>DeVry</strong> <strong>Week</strong> 3 <strong>iLab</strong> 3 <strong>Latest</strong><br />

Complete the following two programs:<br />

Programming Problem 1<br />

Write a program that generates all the factors of a number entered by the user. For instance, the number 12 has the<br />

factors 2 * 2 * 3. This program has the following requirements:<br />

A. The user must enter a positive integer. If the user enters something else, your program should output an error<br />

message and let the user enter a new value. Use a do/while loop to make sure the user input is successful.<br />

B. The factors must be output in increasing order. The lowest factor your program should report is 2.<br />

C. Your program should output 4 factors per line, each factor in a field of 10 characters. (Hint: the number of factors<br />

output determines when to output endl!)<br />

D. You will need a while loop to report the factors. Here are some helpful hints:<br />

1. If (a % b == 0) then a is a factor of b.<br />

2. When you have found a factor, output the factor and then reduce the number you are working with by dividing the<br />

number by the factor… ie) b = b / a;<br />

1. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report<br />

the output. Include steps to deal with error cases as specified above.<br />

2. Identify three test cases, one using a number with 4 factors, one using a negative number, and one using a number<br />

with more than 4 factors. For each of the three test cases show what inputs you will use and what your expected outputs<br />

should be.<br />

3. Write the program to implement your algorithm. Test your program using your test cases.<br />

Programming Problem 2<br />

This program is designed to analyze the growth of two cities. Each city has a starting population and annual growth<br />

rate. The smaller city has the larger growth rate (required). Show the comparative populations of each city year by year<br />

until the smaller city has grown larger than the bigger city.<br />

As an example, Dogville has a population of 5000 growing at 20% annually while Cattown has a population of 7000<br />

growing at 10% annually. The projected populations are:<br />

Year Dogville Cattown<br />

1 6000 7700<br />

2 7200 8470


3 8640 9317<br />

4 10368 10249<br />

1. Identify the inputs and outputs of the problem.<br />

2. Identify the processing needed to convert the inputs to the outputs.<br />

3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report<br />

each output.<br />

4. Identify three significant test cases including one for incorrect input (ie Small town has lower growth rate). For each<br />

of the three test cases show what inputs you will use and calculate what your expected outputs should be.<br />

5. Write the program to implement your algorithm. Test your program using your test cases. For each of the two<br />

programming problems, create a program using Visual C++.Net. Make sure to capture a sample of your program’s<br />

output. The best way to do this is to click on the console window you want to capture and then press the Alt and<br />

PrintScreen keys at the same time. Then paste your captured screen image into a Word document. For each of the<br />

two programs, put the screen capture followed by a copy of your source code into your Word document.<br />

Your final programming document should contain in the following order:<br />

1. Answers to the questions listed above.<br />

2. Screen capture of the first program followed by source code. 3. Screen capture of the second program followed by<br />

source code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!