Given two point charges q1 and q2 , located at a distance d from each other. Write a program that calculates the strength of their mutual attraction. The proportionality coefficient is k = 1/4πϵ0 , where ϵ0 ≈ 8.85 × 10 −12 fm.

The answer to withdraw in the form: "The force of attraction between the charges q1 C and q2 C, located at a distance of d m, is equal to F N.". Instead of letter symbols, there should be concrete numbers with an accuracy of 2 decimal places. Before prompting for input from the keyboard, display a hint.

 using System; namespace ConsoleApplication1 { class Program { static void Main() { double q1, q2, d, k, F; Console.WriteLine("Вычисление силы взаимного притяженияю. Введите q1,q2 и d (расстояние между ними) : "); Console.ReadKey(); Console.WriteLine("Вместо буквенных обозначений должны стоять конкретные числа с точностью до 2-го знака после запятой. Введите q1 : "); q1 = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите q2 : "); q2 = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите d(расстояние между ними) : "); d = Convert.ToDouble(Console.ReadLine()); k = 1 / 4 * 8.85 * 10^(-12); F = k * q1 * q2 / d; Console.WriteLine("" + F); Console.ReadLine(); } } } 
  • I am the author of the problem book from which this task was taken and, apparently, the teacher of the author of the question. I have a big request for him - solve problems on your own! - velikodniy

1 answer 1

10 ^ (- 12)

Because it is xor. Try 1e-12.

k = 1/4 * 8.85 * 10 ^ (- 12);

And maybe you lost brackets somewhere. Carefully what exactly is the denominator.

4πϵ 0

Where did π go in the program?

  • I would also do k = 1E+12 / (4 * 8.85); should be more accurate - Mirdin
  • @Mirdin There in the formula is the number 8.85e-12 , only I do not understand, in the numerator or in the denominator ... UPDATE: Re-read. What is the idea of ​​transferring to the numerator from the denominator? Why more precisely? - Qwertiy
  • 2
    @Mirdin double has a mantissa accuracy limit, not a general accuracy limit. in it the number is represented as (mantissa 1, exponent -12), only in binary form. and there is no difference between (1, -12) and (1, 12). - PashaPash
  • one
    @PashaPash, in fact, 1e12 is visible, but 1e-12 is not. - Qwertiy
  • one
    @Qwertiy yes, I just reminded that the error is not in decimal places, but in significant figures. 8.85 is not exactly accurate, so no difference. - PashaPash