问题:一年约有 3.156×107 s,要求输入您的年龄,显示该年龄合多少秒。
数据范围:
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int age = scan.nextInt(); System.out.print((long)(3.156*Math.pow(10,7)*age)); } }
import java.math.BigInteger; import java.util.Scanner; /** * * @Title 你能活多少秒 * @Description <TODO> * 问题:一年约有 3.156×10^7 s,要求输入您的年龄,显示该年龄合多少秒。 * * 数据范围: 0<age≤200 * @author weijunfu<ijunfu @ qq.com> * @date 2022/03/14 22:37 * @version 1.0.0 * */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); if(in.hasNextInt()) { int age = in.nextInt(); BigInteger value = BigInteger.valueOf(age * 31560000L); System.out.println(value); } in.close(); } }
import java.util.Scanner; public class main6 { public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] str = s.next().split("\\."); String a = str[0].substring(str[0].length()-1); System.out.println(a);
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); System.out.println(BigInteger.valueOf(n * 31560000L)); } scanner.close(); } }
import java.text.NumberFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc1 = new Scanner(System.in); int years = sc1.nextInt(); double result=years*3.156*Math.pow(10,7); NumberFormat resultFormat = NumberFormat.getInstance();//11-14行是取消科学计数法的操作,需要记住 resultFormat.setMaximumFractionDigits(20); resultFormat.setGroupingUsed(false); String a=resultFormat.format(result); System.out.println(a); } }