1import java.util.Scanner;public class test1 { private static Scanner input= new Scanner(System.in); public static void main(String[] args){ long num; do{ System.out.print("\nInput your num: "); num=input.nextLong(); }while(num<10000||num>99999); num=num/100; num*=100; System.out.println("\nThis is num: "+num); }}2.import java.util.Scanner;public class test2 { private static Scanner input= new Scanner(System.in); public static void main(String[] args){ long num; do{ System.out.print("\nInput your num: "); num=input.nextLong(); }while(num<0||num>1000); int sum=0; while(num>0){ sum+=num%10; num/=10; } System.out.println("\nThis is sum: "+sum); }}
标签:java,练习题,编程