Write a Java program that calculates The circumference length and area of the radius of 3.0 and outputs the results.
Note: The System class Math is located in the java.lang packet, and pi Pi can be used by the static properties of the Math class Pi is obtained, which is defined as "public static final Double PI = 3.14159265358979323846;".
import java.lang.* public class Yuan { public static void main (string[] args) {double r = 3.0; double perimeter = 2 * Math.PI * R; double area = R * R * Math.PI; System.out.println ( "perimeter" + perimeter); System.out.println ( area +
Write a Java program to calculate The number of, ..., 9 the 9 numbers can make up the number of different three-bit even numbers with no duplicates.
Public classABCD { Public Static voidMain (string[] args) {intN=0; for(inti=1;i<=9;i++) { for(intj=1;j<=9;j++) { for(intk=1;k<=9;k++) { if(j!=i&&j!=k&&k!=i&&k%2==0) {n+=1; System.out.println (100*i+10*j+k); } }}} System.out.println ("A total of" +n+ "); }}
Seek m+mm+mmm+... +m...m(n ) and, where m is an integer between 1~9.
For example, when m=3,n=4 , ask for 3+33+333+3333 's and.
Requirements: m and n are defined as properties of the class, and M and n are assigned in the constructor.
Public classM {Private intm; Private intN; PublicMintMintN) {Super(); This. m =m; This. N =N; } Public intGetm () {returnm; } Public voidSetm (intm) { This. m =m; } Public intGetn () {returnN; } Public voidSETN (intN) { This. N =N; } Public intAdd () {ints = 0,b = 0; for(inti=0;i<n;i++) {b=b*10+m; System.out.println (b); S=s+b; } returns; } Public Static voidMain (string[] args) {m M=NewM (3,4); System.out.println (M.add ()); }}
Given a positive integer m, count the digits of m , print each digit separately, and print out the numbers in reverse order.
Requirements:m is defined as a property of the class, and the constructor is assigned a value of M, and the value of m is unlimited.
Public classZ {Private intm; PublicZ (intm) {Super(); This. m =m; } Public voidM1 () {String str=m+ ""; System.out.println ("with" +str.length () + "bit"); } Public voidM2 () {String str=m+ ""; System.out.println ("Each digit is:"); for(intI=0;i<str.length (); i++) {System.out.print (Str.charat (i)+" "); } } Public voidM3 () {String str=m+ ""; System.out.println ("\ n Reverse"); for(intI=str.length () -1;i>=0;i--) {System.out.print (Str.charat (i)); } } Public Static voidMain (string[] args) {Z m=NewZ (1234845); M.M1 (); M.M2 (); M.M3 (); }}
Java program design on-Machine Job 1