The deadline for this lab question is Wednesday 28 September 2005, 23:59:59 hours.
The name of your C program file must be called refraction.c, files with any other name will not be marked.
The following shows a sample run,
where $ indicates the Unix prompt. You are reminded to follow the sample
outcome exactly, else marks will be deducted. User input is shown in bold font.
The refraction1.txt data file contains the following lines:
3 //3 substances
5 //1st substance
with 5 experiments
50 50 //experiment 1 of
substance 1
40 41 //experiment 2 of
substance 1
30 30 //....
10 9 //....
60 60 //experiment 5
(last) of substance 13
2
//2nd substance with 2 experiments
35 26 //experiment 1 of substance 2
63 42 //experiment 2 (last) of
substance 2
3 //3rd (last)
substance with 3 experiments
20 8 //experiment 1 of substance 3
50 18 //…
71 23 //experiment 3 (last) of
substance 3
Note that the comments are included
for explanation purpose only, they are not in the actual data
file.
$ gcc -Wall –lm refraction.c -o refraction
$ ./refraction
Substance No.1
Data No.1 Angles (in:50,out:50) RIndex = 1.00
Data No.2 Angles (in:40,out:41) RIndex = 0.98
Data No.3 Angles (in:30,out:30) RIndex = 1.00
Data No.4 Angles (in:10,out:9) RIndex = 1.11
Data No.5 Angles (in:60,out:60) RIndex = 1.00
Average RIndex = 1.02
Substance No.2
Data No.1 Angles (in:35,out:26) RIndex = 1.31
Data No.2 Angles (in:63,out:42) RIndex = 1.33
Average RIndex = 1.32
Substance No.3
Data No.1 Angles (in:20,out:8) RIndex = 2.46
Data No.2 Angles (in:50,out:18) RIndex = 2.48
Data No.3 Angles (in:71,out:23) RIndex = 2.42
Average RIndex = 2.45
Substance No.3 has the maximum refraction index of 2.45
A total of 12 different hosts have accessed this document in the last 445 days; your host, 216.73.216.39, has accessed it 1 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.