CS Answer for classwork 1

Q1

program class1q1; uses wincrt;
var A, B, C : integer;
    x1, x2 : real;
begin
  write('A: ');
  readln(A);
  write('B: ');
  readln(B);
  write('C: ');
  readln(C);
  writeln;
  x1 := (-B+sqrt(B*B-4*A*C))/(2*A);
  x2 := (-B-sqrt(B*B-4*A*C))/(2*A);
  writeln('The roots are ',x1:0:3,' and ',x2:0:3,'.')
end.

Q2a

program class1q2a; uses wincrt;
const G = 6.64E-11;
var m1, m2, r, F : real;
begin
  write('m1: ');
  readln(m1);
  write('m2: ');
  readln(m2);
  write('r: ');
  readln(r);
  writeln;
  F := G*m1*m2/(r*r);
  writeln('The force between two objects is ',F,' N.')
end.

Q2b

program class1q2b; uses wincrt;
const G = 6.64E-11;
var m1, m2, r, F : real;
begin
  write('What is the mass on which the force is acting? ');
  readln(m1);
  write('What is the force acting? ');
  readln(F);
  write('What is the radius? ');
  readln(r);
  writeln;
  m2 := F/G*(r*r)/m1;
  writeln('The mass is ',m2,' kg.')
end.

¡@

download all answers on this page