# C+

| October 29, 2015

Goals: Developing problem-solving skills, declaring variables, multi-way branches, employing loops, and using files Problem: You are to create a program to help in the analysis of data obtained from an x-ray powder diffractometer used to characterize materials.

In the diffractometer a sample is exposed to x-rays of a specific wavelength and a detector placed on a goniometer is used to measure the angles (2-theta values) where constructive interference of the diffracted beam occur (called peaks) and the intensity) where n is the harmonic of the diffracted beam (n = 1 for these experiments),q = 2dsin(lof these peaks. The location of these peaks is dependent on the atomic structure of the material being examined. This relationship is given by Bragg’s law which states n (theta) is the angle between the x-ray beam and the sample of the material. You are to create a program that will read the 2-theta valuesq is the wavelength of the x-ray, d is the interplanar spacing between planes of specific orientation in the material and l))2. The first line of the data file will contain the sample name which should be stored as a string object.qand the intensities from a file and create a table that will contain the 2-theta values, the intensities, the d values and Q values where Q = 1/(sin(The second line will contain the anode (the elemental source of the x-ray) as a 2-character symbol which should also be stored as a string object. You will need to use this symbol to determine the wavelength of the x-ray using the table below. You should assume the format of the 2-character symbol will be an upper case letter followed by a lower case letter and the symbol will be one of those listed in the table below. Anode Wavelength Cu 1.54059 Cr 2.28973 Fe 1.93604 Co 1.78900 Mo 0.70932 The 2-theta (first column) and intensity values (second column) will start on the third line and continue on subsequent lines. The intensity values are whole numbers. You should design your program so it will continue to read data until the end of file is reached. Your output should be a file that contains the name of the sample, the wavelength and a table containing the 2-theta and intensity values from the file plus the calculated d and Q values. The wavelength should be output with 6 significant digits, the 2-theta values with 5 significant digits, the d values with 6 significant digits and the Q values with 7 significant digits. The table that you output should contain column headings then the values similar to the example given below. Your program should allow the user to enter the name of the data file, but you do not need to worry about the folder path (assume the data file is in the same folder as your *.cpp file) and the name of the output file to be generated. A data file called “Project2data.dat” has been placed on ANGEL. This file contains