两个数相除的java程序怎么写( 三 )


BufferedReader in1 = new BufferedReader(
new InputStreamReader(System.in));
dividend = Double.parseDouble(in1.readLine());
System.out.println("请输入除数:");
BufferedReader in2 = new BufferedReader(
new InputStreamReader(System.in));
divisor = Double.parseDouble(in2.readLine());
if(divisor==0)
{
System.out.println("除数不能为零!");
throw new ZeroException("除数不能为零!");
}
else if(divisor
6.Java编程,输入两个数,输出两个数的和这个程序核心是Scanner类的使用
package com.test;
import java.util.Scanner;
public class Test {
public static void main(String[] args)throws Exception{
Scanner s= new Scanner(System.in);
System.out.print("输入第一个数:");
float a=s.nextFloat();
System.out.print("输入第二个数:");
float b=s.nextFloat();
System.out.println("两个数的和是:"+(a+b));
}
}
运行效果如下