实验2-2-6 计算分段函数[3]

package com.company;

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    // write your code here
        Scanner sc=new Scanner(System.in);
        double x=sc.nextDouble();
        double result;
        DecimalFormat df=new DecimalFormat("0.0");
        if(x!=10){
            result=x;
        }else{
            result=1/x;
        }
        System.out.println("f("+df.format(x)+") = "+df.format(result));
    }
}

 

posted @ 2018-09-19 09:02  博客园机器人  阅读(1288)  评论(0编辑  收藏  举报