3
I would like to create a program that makes the electronic distribution of atoms, but I’m not sure how to implement it. Would it be like this? you would put the atomic number and it would return you the electronic distribution (K, L, M, N, O, P, Q).
I thought I’d use if’s considering that the layers have a maximum number of electrons:
K = 2
L = 8
M = 18
N = 32
O = 32
P = 18
Q = 8
But there are 2 rules that are:
- The last layer cannot have more than 8 electrons
- The penultimate layer cannot have more than 18 electrons
These two rules hold all my logic. The question is: Does anyone know a better way to implement this project?
Edit: I got a good part now, but the remaining numbers are the same as the valence one. Can anyone help me correct this mistake?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int z = 53;
int K = 1, L = 555, M = 555, N = 555, O = 555, P = 555, Q = 555;
if (z >= 2) { z -= 2; K = 2; } else { K = z; }
if (z >= 8) { z -= 8; L = 8; }
if (z < 8) L = z;
if (z >= 18) { z -= 18; M = 18; }
if (z <= 8) M = z;
if (z >= 32) { z -= 32; N = 32; }
if (z < 32 && z >= 18) { z -= 18; N = 18; }
if (z <= 8) N = z;
if (z >= 32) { z -= 32; O = 32; }
if (z > 32 && z >= 18) { z -= 18; O = 18; }
if (z <= 8) O = z;
if (z >= 18) { z -= 18; P = 18; }
if (z <= 8) P = z;
if (z >= 8) {z -= 8; Q = 8; }
if (z <= 8) Q = z;
Console.WriteLine("Valores:\nK = " + K + "\nL = " + L + "\nM = " + M + "\nN = " + N + "\nO = " + O + "\nP = " + P + "\nQ = " + Q);
Console.ReadKey();
}
}
}
Post what you have so far so we can have a more solid basis to formulate a help.
– ptkato