Ai
1 Star 0 Fork 0

学C语言的枫子/Java_test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_03_09_2.java 6.73 KB
一键复制 编辑 原始数据 按行查看 历史
学C语言的枫子 提交于 2024-03-09 23:01 +08:00 . Java刷题
import java.util.Scanner;
public class test_03_09_2 {
/* public static void main(String[] args) {
System.out.println("请输入第一个数:");
int m=new Scanner(System.in).nextInt();
System.out.println("请输入第二个数:");
int n=new Scanner(System.in).nextInt();
int min=(m>n)?m:n;
for(int i=min;i>=1;i--)
{
if(m%i==0&&n%i==0)
{
System.out.println("最大公倍数:"+i);
break;
}
}
int max=(m>n)?m:n;
for(int i=max;i<m*n;i++)
{
if(i%m==0&&i%n==0)
{
System.out.println("最小公约数:"+i);
break;
}
}
}*/
/*public static void main(String[] args)
{
System.out.println("请输入两个整数:");
int a=new Scanner(System.in).nextInt();
int b=new Scanner(System.in).nextInt();
int d=zdgys(a,b);
long x=zxgbs(a,b);
System.out.println("最大公约数:"+d);
System.out.println("最下公倍数:"+x);
}
private static int zdgys(int a,int b)
{
int min=a<b?a:b;
for(int i=min;i>=1;i--)
{
if(a%i==0&&b%i==0)
{
return i;
}
}
return 0;
}
private static long zxgbs(int a,int b)
{
int max=a>b?a:b;
for(long i=max; ;i+=max)
{
if(i%a==0&&i%b==0)
{
return i;
}
}
}*/
/*public static void main(String[] args) {
System.out.println("请输入存款全额:");
int money=new Scanner(System.in).nextInt();
System.out.println("请输入存款年限:");
int year=new Scanner(System.in).nextInt();
double outMoney=0;
if(year==1)
{
outMoney=money+money*(2.25/100)*year;
}
else if(year==2)
{
outMoney=money+money*(2.7/100)*year;
}
else if(year==3)
{
outMoney=money+money*(3.25/100)*year;
}
else if(year==5)
{
outMoney=money+money*(3.6/100)*year;
}
else {
System.out.println("输入年限有误,请重新输入!");
}
System.out.println("存款:"+money);
System.out.println("年限:"+year);
System.out.println("本息:"+outMoney);
}
*/
/* public static void main(String[] args)
{
*//*System.out.println("请输入您的税前工资:");
int money=new Scanner(System.in).nextInt();
double before=money-(money*0.1)-5000;
double shui=0;
if(before>00&&before<=3000)
{
shui=before*0.03;
}
else if (before>3000&&before<=12000)
{
shui=3000*0.03+(before-3000)*0.1;
}
else if (before>12000&&before<=25000)
{
shui=3000*0.03+9000*0.1+(before-12000)*0.2;
}
else if (before>25000&&before<=35000)
{
shui=3000*0.03+9000*0.1+13000*0.2+(before-35000)*0.3;
}
else if (before>35000&&before<=55000)
{
shui=3000*0.03+9000*0.1+13000*0.2+10000*0.25+(before-55000)
}*//*
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的税前工资:");
//2.键盘录入税前工资
int money = sc.nextInt();
//3.计算应纳税部分的工资
double before = money - (money*0.1) - 5000;
//4.定义个税变量
double shui = 0;
//5.按照梯度范围计算个税数值
if(before > 0 && before <=3000){
shui = before * 0.03;
}else if(before > 3000 && before <=12000){
shui = 3000*0.03 + (before-3000) * 0.1;
}else if(before > 12000 && before <=25000){
shui = 3000*0.03 + 9000*0.1 + (before-12000)*0.2;
}else if(before > 25000 && before <=35000){
shui = 3000*0.03 + 9000*0.1 + 13000*0.2 + (before-25000)*0.25;
}else if(before > 35000 && before <=55000){
shui = 3000*0.03 + 9000*0.1 + 13000*0.2 + 10000*0.25 + (before-35000)*0.3;
}else if(before > 55000 && before <=80000){
shui = 3000*0.03 + 9000*0.1 + 13000*0.2 + 10000*0.25 + 20000*0.3 + (before-55000)*0.35;
}else if(before > 80000){
shui = 3000*0.03 + 9000*0.1 + 13000*0.2 + 10000*0.25 + 20000*0.3 + 25000*0.35 + (before-80000)*0.45;
}
//6.计算税后工资
double after = money - (money*0.1) - shui;
//7.打印个税和税后工资
System.out.println("个人所得税" + shui + "元");
System.out.println("税后工资" + after + "元");
}
*/
/* public static void main(String[] args) {
//1.提示并接收用户输入的手机号
System.out.println("请输入您预选的手机号:");
String tel = new Scanner(System.in).nextLine();//注意String类型数据一般用nextLine()
//2.调用getPrice()方法,来计算价格,注意需要把手机号tel作为参数传入方法中
getPrice(tel);
}
//3.创建getPrice()
public static void getPrice(String tel) {
//3.1 手机号tel的长度,必须是11位的正确手机号--提前校验,提高程序健壮性
if(tel.length() != 11) {
System.out.println("号码格式错误");
return;//结束方法,返回到调用位置再继续执行
}
*//*比如我们拿到的手机号是tel="2313123123",想要拿到尾数,也就是最后一个字符
* 需要用到 char c = tel.charAt(10)
* 注意:由于下标也是从0开始,所以取第11个字符,它的下标位置是10
*//*
//3.2获取手机号的尾数
char c = tel.charAt(10);
//3.2定义用来保存最终结果的变量price,初始值为0
int price = 0;
//3.3根据c字符的值,来为price重新赋值
switch(c) {
case '8': price=50; break;//尾数为8支付50
case '4': price=0; break;//尾数为4免费
default: price=20;//其他情况需支付20
}
//3.4显示结果
System.out.println("您实际应支付的价格为:"+price);
}
*/
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/learning-c-language-feng/java_test.git
git@gitee.com:learning-c-language-feng/java_test.git
learning-c-language-feng
java_test
Java_test
master

搜索帮助