1. 程式人生 > >第二章作業.

第二章作業.

java ava sta ring ted rgs num ber next

2.6

import java.until.Scanner;
public class ComputeArea{
  public static void main(String[] args){
  Scanner input =new Scanner(System.in);
  System.out.print("Enter a number between 0 and 1000: ");
  double digits =input.nextDouble();
  double sun =digits+digits+digits+digits;
  System.out.println("the sun of the digits " + digits +"is" +sun);

  }
}

2.15

import java.until.Scanner;
public class ComputeDistance{
  public static void main(String[] args){
  Scanner input =new Scanner(System.in);
  System.out.print("Enter x1 and y1 : ");
  System.out.print("Enter x2 and y2: ");
  double point =input.nextDouble();
  double number =(x2-x1)(x2-x1)+(y2-y1)(y2-y1);
  double distance =Math.pow(number,0.5);
  System.out.println("the distance between the two points " + points+"is" +distance);

  }
}

第二章作業.