EP 241 Computer Programming
 


Computer Homeworks


Periodic Table

Consider that a file atomic.txt contains a data of 103 different periodic elements. The first column is a atomic number, the second is the name, the third is symbol and so on. Last two columns are melting point and boiling point in oC respectively. Unknown property of an atom is assigned to a value of -1. Here is the part of the data file:

Write a C++ program that reads the data from the file into suitable vectors and then outputs a menu (given below) to read an option from the keyboard:

*******************************   MENU   ***********************************
*                                                                          *
* 0. Exit                                                                  *
* 1. List properties of a specific atom                                    *
* 2. List all properties of the elements belonging to a group              *
* 3. List all properties of the elements belonging to a period             *
* 4. List all properties of the elements for a given the description       *
* 5. List all properties of the elements for a given the state at STP      *
* 6. List all properties of the elements for a given boiling point range   *
* 7. List all properties of the elements for a given melting point range   *
*                                                                          *
****************************************************************************
what is your choice? 1
  • If the choice is 1 then program must read an atomic number (Z) from the keyboard and output all properties of the chosen element.
    In this case, for Z = 1, the output of the program and its format should look like:
    
    Input atomic number: 4
       4 Beryllium      Be     2   2 Solid     Alkaline-earth-metal        9.0122   1278.0000   2970.0000
    
  • If the choice is 2 then program must read a group number (G) from the keyboard and output all properties of the chosen group.
    In this case, for G = 1, the output of the program and its format should look like:
    
    Input group number: 1
       1 Hydrogen       H      1   1 Gas       Non-metal                   1.0079   -259.3400   -252.8700
       3 Lithium        Li     1   2 Solid     Alkali-metal                6.9410    180.5400   1342.0000
      11 Sodium         Na     1   3 Solid     Alkali-metal               22.9898     97.8100    882.9000
      19 Potassium      K      1   4 Solid     Alkali-metal               39.0983     63.2500    759.9000
      37 Rubidium       Rb     1   5 Solid     Alkali-metal               85.4678     38.8900    686.0000
      55 Cesium         Cs     1   6 Solid     Alkali-metal              132.9055     28.4000    669.3000
      87 Francium       Fr     1   7 Solid     Alkali-metal               -1.0000     27.0000    677.0000
       1 Hydrogen       H      1   1 Gas       Non-metal                   1.0079   -259.3400   -252.8700
       3 Lithium        Li     1   2 Solid     Alkali-metal                6.9410    180.5400   1342.0000
      11 Sodium         Na     1   3 Solid     Alkali-metal               22.9898     97.8100    882.9000
      19 Potassium      K      1   4 Solid     Alkali-metal               39.0983     63.2500    759.9000
      37 Rubidium       Rb     1   5 Solid     Alkali-metal               85.4678     38.8900    686.0000
      55 Cesium         Cs     1   6 Solid     Alkali-metal              132.9055     28.4000    669.3000
      87 Francium       Fr     1   7 Solid     Alkali-metal               -1.0000     27.0000    677.0000
    
  • If the choice is 4 then program must read a description name.
    In this case, for noble gases, the output of the program and its format should look like:
    
    Input a description name: Noble-gas
       2 Helium         He    18   1 Gas       Noble-gas                   4.0026   -272.2260   -268.9340
      10 Neon           Ne    18   2 Gas       Noble-gas                  20.1797   -248.6700   -246.0480
      18 Argon          Ar    18   3 Gas       Noble-gas                  39.9480   -189.2000   -185.7000
      36 Krypton        Kr    18   4 Gas       Noble-gas                  83.7980   -156.6000   -152.3000
      54 Xenon          Xe    18   5 Gas       Noble-gas                 131.2930   -111.9000   -107.1000
      86 Radon          Rn    18   6 Gas       Noble-gas                  -1.0000    -71.0000    -61.8000
    
  • If the choice is 5 then program must read a state name.
    In this case, for Gas, the output of the program and its format should look like:
    
    Input state at STP: Gas
       1 Hydrogen       H      1   1 Gas       Non-metal                   1.0079   -259.3400   -252.8700
       2 Helium         He    18   1 Gas       Noble-gas                   4.0026   -272.2260   -268.9340
       7 Nitrogen       N     15   2 Gas       Non-metal                  14.0067   -209.8600   -195.8000
       8 Oxygen         O     16   2 Gas       Non-metal                  15.9994   -218.4000   -182.9620
       9 Fluorine       F     17   2 Gas       Halogen                    18.9984   -219.6200   -188.4000
      10 Neon           Ne    18   2 Gas       Noble-gas                  20.1797   -248.6700   -246.0480
      17 Chlorine       Cl    17   3 Gas       Halogen                    35.4530   -100.9800    -34.6000
      18 Argon          Ar    18   3 Gas       Noble-gas                  39.9480   -189.2000   -185.7000
      36 Krypton        Kr    18   4 Gas       Noble-gas                  83.7980   -156.6000   -152.3000
      54 Xenon          Xe    18   5 Gas       Noble-gas                 131.2930   -111.9000   -107.1000
      86 Radon          Rn    18   6 Gas       Noble-gas                  -1.0000    -71.0000    -61.8000
    
  • If the choice is 6 then program must read two boiling point values.
    In this case, for [-200,+100], your program must output the elements whose boiling points are in the range [-200,+100] oC.
    The output of the program and its format should look like:
    
    Input a boiling point range: -200.0   +100.0
       5 Boron          B     13   2 Solid     Metalloid                  10.8110     -7.2000     58.7800
       7 Nitrogen       N     15   2 Gas       Non-metal                  14.0067   -209.8600   -195.8000
       8 Oxygen         O     16   2 Gas       Non-metal                  15.9994   -218.4000   -182.9620
       9 Fluorine       F     17   2 Gas       Halogen                    18.9984   -219.6200   -188.4000
      17 Chlorine       Cl    17   3 Gas       Halogen                    35.4530   -100.9800    -34.6000
      18 Argon          Ar    18   3 Gas       Noble-gas                  39.9480   -189.2000   -185.7000
      36 Krypton        Kr    18   4 Gas       Noble-gas                  83.7980   -156.6000   -152.3000
      54 Xenon          Xe    18   5 Gas       Noble-gas                 131.2930   -111.9000   -107.1000
      86 Radon          Rn    18   6 Gas       Noble-gas                  -1.0000    -71.0000    -61.8000
      91 Protactinium   Pa     3   7 Solid     Actinide                  231.0359   1600.0000     -1.0000
      96 Curium         Cm     3   7 Solid     Actinide                   -1.0000   1340.0000     -1.0000
      97 Berkelium      Bk     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
      98 Californium    Cf     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
      99 Einsteinium    Es     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
     100 Fermium        Fm     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
     101 Mendelevium    Md     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
     102 Nobelium       No     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
     103 Lawrencium     Lr     3   7 Solid     Actinide                   -1.0000     -1.0000     -1.0000
    

University of Gaziantep - Department of Engineering Physics (2005 - 2024)