Covalent bonds possess bond-energy and bond-length. Information for various cova
ID: 3640896 • Letter: C
Question
Covalent bonds possess bond-energy and bond-length. Information for various covalent bonds is stored in three columns of a text file. Below is example of one such file “BondFile.txt” (having no column headings).
Single, Double, or Triple Bond
Bond Energy (kJ/mol)
Bond-length (nm)
C|C
370
0.154
C||C
680
0.130
C|||C
890
0.120
C|H
435
0.110
C|N
305
0.150
C|O
360
0.140
C|F
450
0.140
C|Cl
340
0.180
O|H
500
0.100
O|O
220
0.150
O|Si
375
0.160
N|H
430
0.100
N|O
250
0.120
F|F
160
0.140
H|H
435
0.074
• Write a C++ program that:
– Prompts the user for the name of a file that contains information similar to the above. The user enters the file-name from the keyboard. Validate file name for existence.
– Asks the user to choose which of the three columns to read, which the user enters. Validate the choice.
– Prompts the user for a value under that column, and displays all matching row data. If there is no match, display the message “Data not found”.
– Repeat the last two steps until the user decides to quit.
SAMPLE DIALOG (user inputs underlined)
Name of input file: BondFile.txt
Columns to choose
[1] Single, Double or Triple Bond
[2] Bond Energy (kJ/mol)
[3] Bond Length (nm)
Enter choice [1-3, 0 to cancel]: 3
Enter Bond Length (nm): 0.120
Single, Double or Triple Bond: C|||C
Bond Energy (kJ/mol): 890
Single, Double or Triple Bond: N|O
Bond Energy (kJ/mol): 250
Columns to choose
[1] Single, Double or Triple Bond
[2] Bond Energy (kJ/mol)
[3] Bond Length (nm)
Enter choice [1-3, 0 to cancel]: 2
Enter Bond Energy (kJ/mol): 900
Data not found.
Columns to choose
[1] Single, Double or Triple Bond
[2] Bond Energy (kJ/mol)
[3] Bond Length (nm)
Enter choice [1-3, 0 to cancel]: 1
Single, Double or Triple Bond: O|O
Bond Energy (kJ/mol): 220
Bond Length (nm): 0.150
Columns to choose
[1] Single, Double or Triple Bond
[2] Bond Energy (kJ/mol)
[3] Bond Length (nm)
Enter choice [1-3, 0 to cancel]: 0