Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CMPE 150.02 (C LANGUAGE) PROJECT #3
Project Deadline: December 11, 2001 at 17:00.
In the third project, you are supposed to write a program, which takes input data containing
real numbers from the user and does some statistical calculations. Possible calculations are:
 Finding the average
1 n
average   numbersi
n i 1
 Finding maximum and minimum
 Finding the variance
1 n
numbersi  average 2
var iance 

n  1 i 1
 Finding the standard deviation
stdev  var iance
 Any other statistical function, which you can additionally find.
In addition to these queries, your program should be written dynamically, which means that
the size of the input data is variable. Your program should have the following data operations,
such as:
 Show the whole input
 Show a specific value
 Adding new numbers
 Deleting an existing number
 Deleting all numbers
 Replacing an existing number with a new one (replacing is not equal to just deleting
and adding the new number!)
 Sorting all numbers
Here is an example of an output of your program:
>>Welcome to the statistics-calculator….
>>Please select the operation:
1) Data operations
2) Statistical calculations
3) Exit
Choice>>2
Please first enter data!
>>Please select the operation:
1) Data operations
2) Statistical calculations
3) Exit
Choice>>1
>>Please enter the type of the data operation
1) Show the whole input
2) Show a specific value
3) Add numbers
4) Delete a number
5) Delete all numbers
6) Sort the input
7) Replace a number
8) List the options menu again
9) Back to the previous menu
Choice>>1
Please first enter data!
>>Please enter the type of the data operation
Choice>>5
Please first enter data!
>>Please enter the type of the data operation
Choice>>3
Please enter how many numbers you will input: 3
Please enter the input: 2 7 1.1
New data are: 2.0 7.0 1.1
>>Please enter the type of the data operation
Choice>>8
>>Please enter the type of the data operation
1) Show the whole input
2) Show a specific value
3) Add numbers
4) Delete a number
5) Delete all numbers
6) Sort the input
7) Replace a number
8) List the options menu again
9) Back to the previous menu
Choice>>7
Please enter the index of the number: 2
Please enter the new value: 15.4
The number at the position 2 is replaced
The new order is: 2.0 15.4 1.1
>>Please enter the type of the data operation
Choice>>9
>>Please select the operation:
1) Data operations
2) Statistical calculations
3) Exit
Choice>>2
>>Please select the type of the statistical calculation:
1) Calculate the average
2) Find the maximum
3) Find the minimum
4) Calculate the variance
5) Calculate standard deviation
6) List the options menu again
7) Back to the previous menu
Choice>>1
The average is: 6.1667
>>Please select the type of the statistical calculation:
Choice>>2
The maximum value is: 15.4
>>Please select the type of the statistical calculation:
Choice>>6
>>Please select the type of the statistical calculation:
1) Calculate the average
2) Find the maximum
3) Find the minimum
4) Calculate the variance
5) Calculate standard deviation
6) List the options menu again
7) Back to the previous menu
Choice>>5
The standard deviation: 8.0090
>>Please select the type of the statistical calculation:
Choice>>7
>>Please select the operation:
1) Data operations
2) Statistical calculations
3) Exit
Choice>>5
No such operation…
>>Please select the operation:
Choice>>1
>>Please enter the type of the data operation
1) Show the whole input
2) Show a specific value
3) Add numbers
4) Delete a number
5) Delete all numbers
6) Sort the input
7) Replace a number
8) List the options menu again
9) Back to the previous menu
Choice>>1
The whole input is: 2.0 15.4 1.1
>> Please enter the type of the data operation
Choice>>2
Please enter the index of the number: 4
No number at position 4…
>> Please enter the type of the data operation
Choice>>2
Please enter the index of the number: 3
The number at the position 3 is: 1.1
>> Please enter the type of the data operation
Choice>>3
Please enter how many numbers you will input: 2
Please enter the input: 4.5 8.96
New data are: 2.0 15.4 1.1 4.5 8.96
>> Please enter the type of the data operation
Choice>>8
>>Please enter the type of the data operation
1) Show the whole input
2) Show a specific value
3) Add numbers
4) Delete a number
5) Delete all numbers
6) Sort the input
7) Replace a number
8) List the options menu again
9) Back to the previous menu
Choice>>4
Please enter the index of the number: 3
The number at the position 3 is deleted
New data are: 2.0 15.4 4.5 8.96
>>Please enter the type of the data operation
Choice>>5
All numbers are deleted.
>> Please enter the type of the data operation
Choice>>4
Please first enter data!
>> Please enter the type of the data operation
Choice>>3
Please enter how many numbers you will input: 3
Please enter the input: 2.4 7.1 -1.56
>>Please enter the type of the data operation
Choice>>10
No such operation…
>> Please enter the type of the data operation
Choice>>6
Numbers are sorted
The new order is: -1.56 2.4 7.1
>> Please enter the type of the data operation
Choice>>9
>>Please select the operation:
1) Data operations
2) Statistical calculations
3) Exit
Choice>>3
Thank you for using statistics-calculator...
Note that:
1. If the sequence is like 2.0 15.4 1.1 4.5 8.96 2.11 4.78
Then the number in position 3 is 1.1 (do not forget that indices in C start with 0)
2. If the given index exceeds the length of the input sequence, a message should be
given.
3. If there is no data, avoid performing any operations except adding numbers.
4. You do not need to read the input character by character; you can read them as
floating points. You can also use integers for selecting the menu operations.
5. You do not need to do input check while reading the input data.
6. You must do input check in selecting menu operations within the range of the
appropriate menu.





As you can see from the sample output the program has to be menu driven.
Commenting and programming style (identifier names, indentation) of your program
will affect your grade.
Usage of functions will affect your grade.
There will be a %20 decrease per day for late projects.
Before submitting your project, read the policy of this course from
http://www.cmpe.boun.edu.tr/courses/cmpe150/fall2001/02/02c/.
For any further questions on this project see Ismail Sokmen ( [email protected] )at
room HW Lab. Office hours are: Tuesday, 13:00 – 14:00 ; Wednesday 14.00 – 15.00
Submission:
 The project deadline is December 11, 2001 at 17:00, sharp.
 Submit a diskette containing “studentnumber.c” file “studentnumber.exe” file of your
project. (Other format like project3.c will be not accepted!)
 Submit the printout of your code.
 Submit sample outputs.
 You should also submit the source codes via e-mail. ([email protected])
(only the c-files and they have to be zipped!)
Bonus:
 Any other sorting algorithm (merge, quick, insertion...)
 Any other statistical function
 Please specify what you have done as bonus.
Related documents