CSCE 150A Lab Assignment 13 - Data Statistics, Assignments of Computer Science

Lab assignment 13 for csce 150a - problem solving using computers, where students are required to write a program loader to read a data file, compute statistics such as minimum, maximum, and average values, and output the results.

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-hp0-1
koofers-user-hp0-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009
Lab Assignment 13 - 04/23/2009
Name:
Section: 8:00 11:00 12:30 6:30
Problem 1: Working with Data Sets
On the course webpage, download the data file lab13data.txt and store it in your Z: drive (or wherever
you will run your program). This file contains a list of numbers. The first is an integer specifying how many
more numbers are in the file. After that, the other numbers should be interpreted as double type.
You will write a program loader that will open this file, read its contents, and compute some statistics
on the contents:
1. The minimum value among the numbers.
2. The maximum value among the numbers.
3. The average value among the numbers.
These numbers must be computed using file input appropriate for any file of this format. This can also
be done without arrays. Here is a method to use:
1. Open the file.
2. Read in the first integer as a number n, the number of elements.
3. Define variables min,max,sum, and first and initialize them all to zero.
4. Write a for loop to iterate the following block ntimes:
(a) Read a double value xfrom the file.
(b) If first is zero, then set min and max to x.
(c) If xis smaller than min, then set min to x.
(d) If xis bigger than max, then set max to x.
(e) Add xto sum.
5. Calculate average by dividing sum by n.
6. Output the values of min,max, and average.

Partial preview of the text

Download CSCE 150A Lab Assignment 13 - Data Statistics and more Assignments Computer Science in PDF only on Docsity!

CSCE 150A - Problem Solving Using Computers Laboratory - Spring 2009

Lab Assignment 13 - 04/23/

Name:

Section: 8:00 11:00 12:30 6:

Problem 1: Working with Data Sets

On the course webpage, download the data file lab13data.txt and store it in your Z: drive (or wherever you will run your program). This file contains a list of numbers. The first is an integer specifying how many more numbers are in the file. After that, the other numbers should be interpreted as double type. You will write a program loader that will open this file, read its contents, and compute some statistics on the contents:

  1. The minimum value among the numbers.
  2. The maximum value among the numbers.
  3. The average value among the numbers. These numbers must be computed using file input appropriate for any file of this format. This can also be done without arrays. Here is a method to use:
  4. Open the file.
  5. Read in the first integer as a number n, the number of elements.
  6. Define variables min, max, sum, and first and initialize them all to zero.
  7. Write a for loop to iterate the following block n times: (a) Read a double value x from the file. (b) If first is zero, then set min and max to x. (c) If x is smaller than min, then set min to x. (d) If x is bigger than max, then set max to x. (e) Add x to sum.
  8. Calculate average by dividing sum by n.
  9. Output the values of min, max, and average.