当前位置: 首页 > news >正文

深圳谷歌seo培训班seo资料网

深圳谷歌seo培训班,seo资料网,厦门网站推广优化哪家好,企业网站咋做键盘录入 Java里面有一个类叫Scanner#xff0c;可以接收键盘输入的数字 第一步#xff1a;导包#xff0c;找Scanner这个类 import java.util.Scanner; 导包必须在类定义的上边#xff08;public class上面#xff09; 第二步#xff1a;创建对象#xff0c;开始使用Sc… 键盘录入 Java里面有一个类叫Scanner可以接收键盘输入的数字 第一步导包找Scanner这个类 import java.util.Scanner; 导包必须在类定义的上边public class上面 第二步创建对象开始使用Scanner这个类 Scanner sc new Scanner(System.in); sc为变量名可以改变其他不能改 第三步接收数据 int i sc.nextInt(); i为变量名可以改变其他不能改 注意这种方式只能接收整数输入字符小数会报错 //1.导包 import java.util.Scanner;public class HelloWorld {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请在你的键盘上输入);//3.接收数据变量i记录键盘录入数据int i sc.nextInt();System.out.println(i);} } 进阶练习1用键盘录入实现两数和 //1.导包 import java.util.Scanner;public class HelloWorld {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请在你的键盘上输入第一个数);//3.接收数据变量:记录键盘录入数据int number1 sc.nextInt();System.out.println(请在你的键盘上输入第一个数);int number2 sc.nextInt();int sum number1 number2;System.out.println(两数和为 sum);} } 进阶练习2输入一个三位数分别输出个位十位百位数字 //1.导包 import java.util.Scanner; public class index {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请在你的键盘上输入一个三位数);//3.接收数据变量记录键盘录入数据int number sc.nextInt();System.out.println(个位数是 number % 10);System.out.println(十位数是 number / 10 % 10);System.out.println(百位数是 number / 100 % 10);} }进阶练习3你和你的对象正在试图餐厅获得一张桌子键盘录入两个整数表示你们衣服的时髦度(0~10之间不能录入其他)如果你的时髦度大于你对象那么相亲成功输出true否则输出false //1.导包 import java.util.Scanner; public class index {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请输入我们自己衣服的时髦度);//3.接收数据变量:记录键盘录入数据int myFashion sc.nextInt();System.out.println(请输入我们对象衣服的时髦度);int girlFashion sc.nextInt();boolean result myFashion girlFashion;System.out.println(result);} } 进阶练习4键盘录入两个整数如果其中一个为6则最终输出true如果他们的和是6的倍数最终输出true否则输出false //1.导包 import java.util.Scanner; public class index {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请输入第一个整数);//3.接收数据变量:记录键盘录入数据int number1 sc.nextInt();System.out.println(请输入第二个整数);int number2 sc.nextInt();boolean result number1 6 || number2 6 || (number1 number2) % 6 0;System.out.println(result);} } 进阶练习5动物园里有两只老虎请你输入两只老虎的体重通过程序判断是否相同 //1.导包 import java.util.Scanner; public class index {public static void main(String[] args) {//2.创建对象表示我现在要用Scannner这个类Scanner sc new Scanner(System.in);System.out.println(请输入第一只老虎的体重);//3.接收数据变量:记录键盘录入数据int weight1 sc.nextInt();System.out.println(请输入第二只老虎的体重);int weight2 sc.nextInt();String result weight1 weight2 ? 相同 : 不同;System.out.println(result);} }
http://www.yutouwan.com/news/270214/

相关文章:

  • 如何在网站做404页面去视频网站做编辑器
  • 网站建设中的服务器搭建方式建筑网格布
  • 网站开发技术人员怎样设置网站关键词
  • 网站加载进度条作风建设年 网站
  • htm5网站ai效果图网站
  • 深圳微信网站设计东莞网站建设流程图
  • xyz域名的网站有哪些苏州网站建设招聘
  • 网站维护 上海软件平台制作
  • ks2e做网站做网站阿里云买哪个服务器好点
  • 温州建设小学 网站首页博客网站入口
  • 旅游示范校建设专题网站wordpress是什么平台
  • 我英文网站建设开网店怎么开的
  • 做网站能用本地的数据库嘛视频网站管理系统
  • 杂志社网站建设方案广告公司管理系统软件
  • 淮安市建设银行网站360网站推广官网硅钙钾镁肥
  • 常用博客建站程序广西网站建设价格多少
  • 企业网站栏目设计网站制作系统哪个好
  • 海外自建站服务器维护中是什么意思
  • 广州网站建设电话销售方案
  • 有免费做推广的网站吗惠州做学校网站
  • 网站 版式wordpress 使用ajax
  • 班级网站界面用什么网站做框架图
  • 二手服务器做网站WordPress无图片主题
  • 网站备案账号密码网站建设系统
  • 军队 网站备案网站seo文章该怎么写
  • 个人网站主页花生棒 做网站
  • 企业管理系统网站专业网站的建设设行吗
  • 网站建设哪里有学2022中国互联网公司排名
  • 做外贸的网站主要有哪些内容网站论坛模板下载
  • 百度关键字搜索到自己的网站网站开发图片存哪里