博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Java]控制台输入两个整数,求和差积商后输出
阅读量:3940 次
发布时间:2019-05-24

本文共 505 字,大约阅读时间需要 1 分钟。

新姿势:Scanner

基本语法:

//从键盘接收数据

Scanner s = new Scanner(System.in);

import java.util.Scanner;public class java02 {    //控制台输入两个整数,求和差积商后输出	public static void main(String[] args) {		//从键盘中读取输入数据		Scanner s = new Scanner(System.in);		//声明变量a和b,赋值为输入的整数		System.out.println("请输入第一个整数");		int a = s.nextInt();		System.out.println("请输入第二个整数");		int b = s.nextInt();		//计算a和b的和积差商		System.out.println("和="+(a+b));		System.out.println("差="+(a-b));		System.out.println("积="+(a*b));		System.out.println("商="+(a/b));	}}

 

转载地址:http://avnwi.baihongyu.com/

你可能感兴趣的文章
3.8 - Using the Print Function
查看>>
3.9.1 - Lists in Python
查看>>
3.9.2 - Lists - Adding and Removing Objects
查看>>
3.9.3 - Sorting Lists
查看>>
3.10 - Maya Commands: ls
查看>>
3.11 - Dictionaries in Python
查看>>
3.12 - Tuples in Python
查看>>
4.4 - For Loops
查看>>
4.2.2 - Logical and/or Operators
查看>>
Lesson 4 Part 2 Softmax Regression
查看>>
文章中运用到的数学公式
查看>>
Projective Dynamics: Fusing Constraint Projections for Fast Simulation
查看>>
从2D恢复出3D的数据
查看>>
glm 中 数据类型 与 原始数据(c++ 数组)之间的转换
查看>>
Derivatives of scalars, vector functions and matrices
查看>>
the jacobian matrix and the gradient matrix
查看>>
VS2010 将背景设为保护色
查看>>
ubutun里面用命令行安装软件
查看>>
ubuntu 常用命令
查看>>
SQLite Tutorial 4 : How to export SQLite file into CSV or Excel file
查看>>