بســم الله الـرحمــن الرحيــم
السلام عليكــم ورحمـة الله وبركاتــة ،،
اذا ممكن تساعدوووني ، عندي واجب اني اعمل برنامج و هو :
---------------------------------------------------
PART A
Write the definition a structure type named Element_Type that represents a chemical element. The structure Element_Type should include:
• Name of the element (name) of type string.
• Atomic weight of the element (weight) of type float.
• Number of electrons in each shell (numElectrons []) which is represented by an array of int
with size 7.
Example: The chemical element SODIUM has a name Sodium, a weight 22.9898, and the number of electrons in the seven shells is:
2
8
1
0
0
0
0
PART B
1. Write a function named Average_electrons (Element_Type elt) that takes as parameters a variable of Element_Type. The function should return the average number of electrons in the element.
2. Write a function named Maximum_electrons_inShell (Element_Type elt) that takes as parameters a variable of Element_Type. The function should return the number of shell with maximum electrons.
PART C
Write a main function to test your program
--------------------------------------
و هاذه شغلي .. فيه أخطاء ابي تساعدووني فيها اذا سمحتواا ..
---------------------
#include<iostream>
#include<string>
using namespace std;
struct Element_Type
{
string name;
float weight;
int numElectrons[7];
}
void Average_electrons(Element_Type elt)
{
int sum=0;
float avg;
for(int i=0 ; i<=6 ; i++)
sum+= numElectrons;
avg= sum/7;
}
void Maximum_electrons_inShell (Element_Type elt)
{
int max;
for(int i=0 ; i<=6 ; i++)
{
max= numElectrons;
if(numElectrons < numElectrons[i+1])
max= numElectrons[i+1];
}
}
int main()
{
Element_Type elt;
float avg;
cout<<"enter chemical element:";
cin>> elt.name >> endl;
cout<<"enter weight:";
cin>> elt.weight >> endl;
cout<<"enter numElectrons:";
for (int i=0; i<6; i++)
cin>> elt.numElectrons >> endl;
return 0;
}
-------------------------------