nynw.net
当前位置:首页 >> 编写一个JAVA应用程序,用户从键盘只能输入整数,... >>

编写一个JAVA应用程序,用户从键盘只能输入整数,...

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.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...

package com.xiajunyu.demo1;import java.util.Scanner;/** * 编写一个Java应用程序,用户从键盘只能输入整数,程序输出这些整数的乘积。要求: 定义具有3个元素的整型数组; * 利用Scanner对象获得从键盘输入的数据,赋值给数组元素; 求数组元素...

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 ee { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int total=1; int a=0; while(a>-1){ a=scanner.nextInt(); total=total*a; System.o...

import java.util.Random; import java.util.Scanner; public class Du { public static void main(String[] args) { int rightNum = new Random().nextInt(100) + 1; Scanner scanner = new Scanner(System.in); int input = 0; do{ System.out...

import java.util.Scanner;public class Demo {public static void main(String[] args) {Scanner s = new Scanner(System.in);double d = s.nextDouble();System.out.println(String.format("%.2f", d));}}

代码如下: 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("请输入一个数:")...

你是C程序员过来的吧,明显的C风格, Scanner牵扯到线程的,要放到循环里面去,整个程序以0结束。修改如下: import java.util.Scanner; public class Multi { public static void main(String args[]) { long mul = 1; long a = 1; while(a != ...

import java.util.Scanner;public class Test {public static void main(String[] args) {Scanner sc = new Scanner(System.in);System.out.println("输入x:");String x;do {try {x = sc.nextLine();if (Integer.valueOf(x) instanceof Integer...

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