acmore|acmore.cc1011将磅转换为千克1012财务应用程序:计算消费1013求一个整数各位数的和1014求出年数1015求ASCII码对应的字符

1011:

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sca = new Scanner(System.in);
        double b = sca.nextDouble();
        double k = b*(0.454);
        if (k<=1) {
            System.out.printf("%.1f"+" kilogram",k);
        }
        else {
            System.out.printf("%.1f"+" kilograms",k);
        }


        }
    }

1012:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        double a = sca.nextDouble();
        double b = sca.nextDouble();
        double c,d;
        b = b/100;
        c = a*b;
        d = c+a;
        System.out.printf("The gratuity is "+"%.2f"+" and total is "+"%.2f",c,d );

    }
}

1013:

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sca = new Scanner(System.in);
        int a = sca.nextInt();
        int b,c,d,e;
        if (a!=1000){
        b = a%10;
        c = (a-b)%100;
        d = c/10;
        e = (a-b-c)/100;
        System.out.println("The sum of the digits is "+(b+d+e));
        }
        else {
            System.out.println("The sum of the digits is 1");
        }
    }
}

1014:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        double a = sca.nextDouble();
        double b, c, d;
        if (a!= 0) {
            b = a % (365 * 24 * 60);// 剩余分钟数
            c = b / (24 * 60);//天数
            d = (a - b) / (365 * 24 * 60);//年数
            if (d == 1 && c == 1) {
                System.out.println("Approximately " + "1" + " year " + "1" + " day");
            } else if (d == 1 && c != 1 && c != 0) {
                System.out.println("Approximately " + "1" + " year " + (int) c + " days");
            } else if (d != 1 && c == 1 && d != 0) {
                System.out.println("Approximately " + (int) d + " year " + "1" + " day");
            } else if (d == 0 && c == 1) {
                System.out.println("Approximately " + "1" + " day");
            } else if (d == 1 && c == 0) {
                System.out.println("Approximately " + "1" + " year ");
            }
            else {
                System.out.println("Approximately " +(int)d+ " years " +(int)c+ " days");
            }

            }
               else {
                System.out.println();
            }


            }
        }

1015:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        int a = sca.nextInt();
        if (a>=33&&a<=126) {
            char x = (char)a;
            System.out.println("The character for ASCII code "+a+" is "+x);

        }
    }
}

acmore


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值