设计一个方法,将一个小于2147483647的double类型变量以截断取整方式转化为int类型
输入描述:
随机double类型变量
输出描述:
转化后的int类型变量
代码:
计算:
描述
输入两个正整数a和b,输出这两个正整数的和,差,积,商,模(若a>b则输出a-b,a/b,a%b的值反之输出b-a,b/a,b%a的值,不考虑小数,请使用int类型)
输入描述:
两个正整数
输出描述:
它们的和,差,积,商,模。每个值之间用空格隔开
四舍五入:
定义一个int类型变量i,i为由浮点数变量d四舍五入后的整数类型,请将转换后的i进行输出
输入描述:
用户随机输入的浮点数
输出描述:
四舍五入之后的整数(小数点后一位>=5则进一,否则舍去)
交换变量值
描述
在不使用第三个变量的情况下交换两个int类型变量的值
输入描述:
a变量和b变量的值
输出描述:
交换后a变量和b变量的值,中间用空格隔开
代码:
计算商场折扣:
牛牛商场促销活动:
满100全额打9折;
满500全额打8折;
满2000全额打7折;
满5000全额打6折;
且商场有抹零活动,不足一元的部分不需要付款(类型强制转换)
牛大姨算不清楚自己应该付多少钱,请你帮忙算一下
强制类型转换(int)(price*0.9)加两个括号
体重指数 = 体重 (kg) / ( 身高 (m) × 身高 (m) ),小于18.5属于偏瘦,介于18.5和20.9之间(左闭右开)属于苗条,介于20.9和24.9之间(左闭右闭)属于适中,超过24.9属于偏胖。下面由你来编写一段逻辑,算出输入了身高和体重的用户的体重指数,并返回他们的身材状态。(体重指数请使用double类型)
输入描述:
用户的身高(m)和用户的体重(kg)
输出描述:
体重指数代表的用户身材状态
学生等级:
描述
现有如下成绩等级A,B,C,D。其中A代表优秀,B代表良好,C代表及格,D代表不及格。现在请你来为学生的成绩进行分级,如果用户输入错误则输出未知等级。
输入描述:
成绩等级对应的中文表述
输出描述:
优秀,良好,及格,不及格,未知等级
代码:
判断字符串相等就equals方法
正则表达式是否合法:
请根据给出的正则表达式来验证邮箱格式是否合法,如果用户输入的格式合法则输出「邮箱格式合法」,否则输出「邮箱格式不合法」。
输入描述:
任意字符串
输出描述:
根据输入的邮箱格式判断其合法于不合法,若输入字符串符合邮箱格式则输出邮箱格式合法,否则输出邮箱格式不合法
str.mtaches(“正则表达式”);str是否满足正则表达式
?:选择运算符:化简代码
求和:
有数列为:9,99,999,...,9999999999。要求使用程序计算此数列的和,并在控制台输出结果。(请尝试使用循环的方式生成这个数列并同时在循环中求和)
都用long类型
正数个数:
控制台输入整数,请设计一个死循环,当用户输入非正数时停止输入。请给出用户输入的正整数个数(默认输入个数不超过2147483647)