Difference: LabKenyon (1 vs. 11)

Revision 112018-03-01 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Line: 6 to 6
 

Lab 6 - Tallying

Due: March 28, 11:55pm

Changed:
<
<
Moodle Link
N001_0690_002.jpg
>
>
Moodle Link
N001_0690_002.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 102017-03-28 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Line: 42 to 41
 

Hints

  1. Don't try to code this program until you work out an algorithm on paper, and can manually step through it on paper!
  2. It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.
Changed:
<
<
  1. Use additional arrays to store the unique numbers found, and the matching counts for each of those unique numbers.
>
>
  1. You could use additional arrays to store the unique numbers found, and the matching counts for each of those unique numbers. There is a more efficent method without using extra arrays.
 
  1. You will need to break this up into functions. Do no attempt to do it all in a single program. Some likely functions:
Added:
>
>
    • Enter Array
 
    • Sort array of integers (given array)
Changed:
<
<
    • Display solution table (given arrays)
    • Tally numbers in an array
>
>
    • Display solution table using the sorrted array
    • Tally numbers in an array (only if you create intermediate arrays)
 

Turn In

Runs of the following:

Revision 92017-01-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 6 - Tallying

Changed:
<
<

Due: Oct 25, 11:55pm

>
>

Due: March 28, 11:55pm

 
Changed:
<
<
Moodle Link
N001_0690_002.jpg
>
>
Moodle Link
N001_0690_002.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 82016-10-20 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Line: 6 to 6
 

Lab 6 - Tallying

Due: Oct 25, 11:55pm

Changed:
<
<
Moodle Link
N001_0690_002.jpg
>
>
Moodle Link
N001_0690_002.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
Line: 15 to 14
 
  • You will need to do a sort for this problem. You may use the sort function given in class, or write your own!

Grading Table

Requirement Grading Comments Points Score
Changed:
<
<
Good clean, easy to understand input and output operations (All sort code included)   10  
Program handles input error conditions appropriately   10  
Complete source code with good formatting and organization, variables names, and comments   10  
>
>
Easy to use user interface   10  
C++ code includes comments, with project information at top, pre and post conditions for each functions and other cmments as needed.   10  
The C++ code has good formatting, indentation, and organization.   10  
Good variable and function names, appropriate use of constants rather then literal numbers.   10  
 
Functions: Logic divided up into cohesive functions with a single purpose   20  
Changed:
<
<
Runs: Run examples from trials with correct output on required trial data   50  
>
>
Runs: Run examples from trials with correct output   40  
Total   100  
 

Problem

Line: 42 to 43
 
  1. Don't try to code this program until you work out an algorithm on paper, and can manually step through it on paper!
  2. It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.
  3. Use additional arrays to store the unique numbers found, and the matching counts for each of those unique numbers.
Added:
>
>
  1. You will need to break this up into functions. Do no attempt to do it all in a single program. Some likely functions:
    • Sort array of integers (given array)
    • Display solution table (given arrays)
    • Tally numbers in an array
 

Turn In

Runs of the following:

Revision 72016-10-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Added:
>
>
 

Lab 6 - Tallying

Changed:
<
<

Due: Oct 20, 11:55pm

>
>

Due: Oct 25, 11:55pm

Moodle Link

 
N001_0690_002.jpg

Instructions

Line: 64 to 67
 

Changed:
<
<
  • N001_0690_002.jpg:
>
>
  • N001_0690_002.jpg:
 
META FILEATTACHMENT attachment="N001_0690_002.jpg" attr="" comment="" date="1475260885" name="N001_0690_002.jpg" path="N001_0690_002.jpg" size="1539701" user="JimSkon" version="1"

Revision 62016-09-30 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
Changed:
<
<

Lab 6

>
>

Lab 6 - Tallying

 

Due: Oct 20, 11:55pm

Added:
>
>
N001_0690_002.jpg

 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
Line: 59 to 64
 

Added:
>
>
  • N001_0690_002.jpg:

META FILEATTACHMENT attachment="N001_0690_002.jpg" attr="" comment="" date="1475260885" name="N001_0690_002.jpg" path="N001_0690_002.jpg" size="1539701" user="JimSkon" version="1"

Revision 52016-09-29 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 6

Due: Oct 20, 11:55pm

Line: 11 to 11
 
Good clean, easy to understand input and output operations (All sort code included)   10  
Program handles input error conditions appropriately   10  
Complete source code with good formatting and organization, variables names, and comments   10  
Changed:
<
<
Funcitons: Logic divided up into cohesive functions with a single purpose   20  
>
>
Functions: Logic divided up into cohesive functions with a single purpose   20  
 
Runs: Run examples from trials with correct output on required trial data   50  

Problem

Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error message, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of that element. The list should be sorted on entries in the first column, smallest to largest.

Changed:
<
<
For example, for the following input
>
>
For example, for the following input:
 
Input the number of entries: 16
Enter the numbers:-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12
Number  Count

Line: 54 to 54
  Show how the program responds to bad input with too many entries (>50) selected, and zero numbers selected.
Changed:
<
<
Solutions
>
>
Solutions
 

Revision 42016-09-29 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 6

Due: Oct 20, 11:55pm

Instructions

Deleted:
<
<
  • Do the problem below that you did not do on Lab 5
 
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
Changed:
<
<

Grading

>
>
  • You will need to do a sort for this problem. You may use the sort function given in class, or write your own!

Grading Table

Requirement Grading Comments Points Score
Good clean, easy to understand input and output operations (All sort code included)   10  
Program handles input error conditions appropriately   10  
Complete source code with good formatting and organization, variables names, and comments   10  
Funcitons: Logic divided up into cohesive functions with a single purpose   20  
Runs: Run examples from trials with correct output on required trial data   50  
 
Changed:
<
<
Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%

Problem 1

>
>

Problem

 
Changed:
<
<
Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.
>
>
Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error message, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of that element. The list should be sorted on entries in the first column, smallest to largest.
  For example, for the following input
Input the number of entries: 16
Enter the numbers: -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12

Added:
>
>
Number Count -12 4 -1 1 1 4 2 2 3 3 4 2
 
Changed:
<
<
the output should be

N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Hint

It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.

>
>

Hints

  1. Don't try to code this program until you work out an algorithm on paper, and can manually step through it on paper!
  2. It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.
  3. Use additional arrays to store the unique numbers found, and the matching counts for each of those unique numbers.
 

Turn In

Changed:
<
<
A run with a 10 numbers, and a run 30 numbera


Problem 2

Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.

The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern.

The program then searches the larger array for a sub-sequence of numbers that matches the pattern. It will continue to search until it finds all instances of that pattern, counting the matches. (Note that for this exercise patterns cannot overlap, e.g. when you find a pattern, start searching for then next only AFTER the previous pattern.

The program will then report the number of matching, and then ask for another pattern to be entered.

If the user enters a negative number when as the first number in a pattern, the pattern is empty, and the program terminates.

If the user enters a pattern that is longer then the search array, give the user an error.

Example:

Enter up to 100 integers:
1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 -1
Enter a pattern: 2 -1
Matches:1  Pattern 2

Enter a pattern: 6 8 5 -1
Matches:3  Pattern 6 8 5

Enter a pattern: -1
Good bye!

>
>
Runs of the following:

Trials

#1

Input the number of entries:40
Enter the numbers:3 5 4 5 7 6 8 2 3 2 3 1 2 1 1 1 5 4 5 6 4 6 4 6 4 2 5 4 6 2 7 6 7 4 8 5 7 8 9 2

 
Added:
>
>

#2

Input the number of entries:20
Enter the numbers:23 54 23 -12 54 34 54 -34 14 0 -17 54 -12 0 0 54 34 0 12 45

#3

Input the number of entries:50
Enter the numbers:1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 
 
Changed:
<
<
</pre>
>
>

#4

 
Changed:
<
<
Turn in:
>
>
Show how the program responds to bad input with too many entries (>50) selected, and zero numbers selected.
 
Changed:
<
<
1. A search in array "3 6 4 7 8 4 6 2 4 10 4 8 6 5 4 6 4 6 8 6 5 6 4 2 7 9 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6"
>
>
Solutions
 
Changed:
<
<
  • Search for 3
  • Search for 6 4 2
  • Search for 6 6 4 7 8
  • Search for 5 4 3 2 1
2. A search in array "1 2 3 4 5 6 7 8 9 10"
>
>

 
Deleted:
<
<
  • Search for 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10 11
 \ No newline at end of file
Added:
>
>

Revision 32016-08-24 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 6

Changed:
<
<

Due: Oct 21, 11:55pm

>
>

Due: Oct 20, 11:55pm

 

Instructions

  • Do the problem below that you did not do on Lab 5

Revision 22015-10-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 6

Due: Oct 21, 11:55pm

Instructions

Changed:
<
<
  • Do the problem below that you did not do on Lab 5 (the other is due the next week)
>
>
  • Do the problem below that you did not do on Lab 5
 
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Grading

Line: 14 to 14
 
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%
Changed:
<
<

Problems

>
>

Problem 1

 
Changed:
<
<
1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.
>
>
Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.
  For example, for the following input
Line: 35 to 35
 
-12 4

Hint

Changed:
<
<
It is MUCH easier to make the number of occurances if you sort the numbers first, then do the counting.
>
>
It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.

Turn In

 
Changed:
<
<
Turn in: A run with a 10 numbers, and a run 30 numbera
>
>
A run with a 10 numbers, and a run 30 numbera
 
Changed:
<
<
2. Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.
>
>

Problem 2

Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.

  The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern.

Revision 12015-10-15 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

Lab 6

Due: Oct 21, 11:55pm

Instructions

  • Do the problem below that you did not do on Lab 5 (the other is due the next week)
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Grading

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%

Problems

1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

For example, for the following input

Input the number of entries: 16
Enter the numbers: -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12

the output should be

N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Hint

It is MUCH easier to make the number of occurances if you sort the numbers first, then do the counting.

Turn in: A run with a 10 numbers, and a run 30 numbera


2. Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.

The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern.

The program then searches the larger array for a sub-sequence of numbers that matches the pattern. It will continue to search until it finds all instances of that pattern, counting the matches. (Note that for this exercise patterns cannot overlap, e.g. when you find a pattern, start searching for then next only AFTER the previous pattern.

The program will then report the number of matching, and then ask for another pattern to be entered.

If the user enters a negative number when as the first number in a pattern, the pattern is empty, and the program terminates.

If the user enters a pattern that is longer then the search array, give the user an error.

Example:

Enter up to 100 integers:
1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 -1
Enter a pattern: 2 -1
Matches:1  Pattern 2

Enter a pattern: 6 8 5 -1
Matches:3  Pattern 6 8 5

Enter a pattern: -1
Good bye!

</pre>

Turn in:

1. A search in array "3 6 4 7 8 4 6 2 4 10 4 8 6 5 4 6 4 6 8 6 5 6 4 2 7 9 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6"

  • Search for 3
  • Search for 6 4 2
  • Search for 6 6 4 7 8
  • Search for 5 4 3 2 1
2. A search in array "1 2 3 4 5 6 7 8 9 10"

  • Search for 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10 11
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback