mdsk.net
当前位置:首页 >> jAvA语言编写一个程序,从键盘输入一个整数,将其转... >>

jAvA语言编写一个程序,从键盘输入一个整数,将其转...

public class Main{public static void main(String[] args) {System.out.println("请输入整数:");Scanner sc=new Scanner(System.in);String input = sc.nextLine();//读取输入字符try{int i = Integer.parseInt(input);//string转intString re...

直接转换成整数,就可以完成取整,具体代码如下: import java.util.Scanner; public class App12 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); float f = scanner.nextFloat(); // 取整数部分 int r...

import java.util.Scanner; public class Demo1 { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int number = 0; int sum = 0; System.out.println("输入一个数,按回车输入下一个数:"); for(int i=0;i

System.out.println("输入数字");Scanner input = new Scanner(System.in);Integer k = input.nextInt();for (int i = 0; i

import java.util.Scanner;public class Test {public static void main(String[] args) {Scanner sc = new Scanner(System.in);System.out.println("请输入一个三位整数");int n = sc.nextInt();while(n>0){System.out.print(n%10);n/=10;}}}

import java.util.Scanner; public class Multi { public static void main(String[] args) { Scanner read = new Scanner(System.in); long mul=1; long a; a= read.nextInt(); while (a!=0) { mul=mul*a; a=read.nextInt(); } System.out.prin...

import java.util.Scanner; public class Test { public static void main(String[] args) { System.out.print("请输入第一个整数:"); Scanner s=new Scanner(System.in); int a=s.nextInt(); System.out.print("请输入第二个整数:"); int b=s...

代码如下: import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.println("请输入一个数:")...

import java.util.Scanner; public class Qh{ public static void main(String[] args){ Scanner input=new Scanner(System.in); System.out.println("请输入:"); int a=input.nextInt(); int b=a/10000; int c=a%10000; int d=c/1000; int e=c...

import java.math.*;import java.util.*;final class MulDemo { public static void main(String... args) { Scanner scaner = new Scanner(System.in); System.out.print("输入非零整数(0表示结束输入):"); BigDecimal bigDec = new BigDecimal...

网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com