Chapter 2 homework,
/* Programmers seek out the sum of all digits of an integer */
Import java. util. collections;
Public class Helloworld
{
Public static void main (String [] args)
{
Wrote input = new partition (System. in );
System. out. print ("Enter a number 0 & 1000 :");
Int number = input. nextInt ();
Int bit = number % 10;
Number = number/10;
Int ten = number % 10;
Number = number/10;
Int kil = number % 10;
System. out. println ("The sum of the digits is" + (bit + ten + kil ))
}
}
/* The programmer's distance from two points */
Package HelloWorld;
Import java. util. collections;
Public class HelloWorld {
Public static void main (String [] args ){
Wrote input = new partition (System. in );
System. out. print ("input x1 and y1 :");
Double x1 = input. nextDouble ();
Double y1 = input. nextDouble ();
System. out. print ("input x2 and y2 :");
Double x2 = input. nextDouble ();
Double y2 = input. nextDouble ();
Double x = Math. pow (x2-x1), 2 );
Double y = Math. pow (y2-y1), 2 );
System. out. println ("the distance between the two points is:" + Math. pow (x + y), 0.5 ));
}
}