#include #include #include using namespace std; int main() { string symbols[120], names[120]; int atnos[120]; double atwts[120]; ifstream elf; elf.open("new.txt"); if (elf.fail()) { cout << "Can't open the file\n"; exit(1); } int pos = 0; while (true) { string symbol, name; int atno; double atwt; elf >> symbol >> name >> atno >> atwt; if (elf.fail()) break; symbols[pos] = symbol; names[pos] = name; atnos[pos] = atno; atwts[pos] = atwt; pos += 1; } elf.close(); while (true) { string wanted; cout << "Enter a symbol: "; cin >> wanted; if (cin.fail()) break; bool found = false; for (int i = 0; i < pos ; i += 1) { if (symbols[i] == wanted) { cout << "Symbol: " << symbols[i] << "\n"; cout << "Name " << names[i] << "\n"; cout << "atomic number: " << atnos[i] << "\n"; cout << "atomic weight: " << atwts[i] << "\n"; found = true; } } if (found == false) { cout << "Symbol " << wanted << " was not found\n"; exit(1); } } }