Piecewise function evaluation
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description

There are the following piecewise functions
F(x) = x^2 + 1 When x> 0 Time ;
F(x) = -x When x<0 Time ;
F(x) = 100.0 When x=0 Time ;
Programming depends on the input x(x Is a real number ), Output its corresponding function value
Input

Multi group input , Each group has one real number x. Process to the end of the file .
Output

For each group of inputs x, Output its corresponding F(x), One line per group , Results reserved 1 Decimal place .
Sample Input

8.00
-5.0
Sample Output

65.0
5.0
Hint
import java.text.DecimalFormat; import java.util.Scanner; public class Main {
public static void main(String[] args) { Scanner str = new Scanner(System.in);
DecimalFormat df =new DecimalFormat("0.0"); double x, y; while(str.hasNext()) {
x = str.nextDouble();if(x > 0) { y = x * x + 1; } else if(x < 0) { y = - x; }
else y = 100.0; System.out.println(df.format(y)); } str.close(); } }

Technology
©2020 ioDraw All rights reserved
python gui Interface examples -Python GUI Programming complete example vue element-ui Drop down menu with search algorithm : Longest common subsequence ( Output all longest common subsequences ) First knowledge Mongdb Data query ( three ) The problem of time type conversion “2021-01-20T10:09:11Z” Morphological processing gradient , Top hat , Black hat mean value - Implementation and application of variance model _python_ Data analysis _9 Wechat small program student course selection system app Design CCF A series of questions --2016 year 4 Month 1 Calculation of break point laravel The first mock exam is based on the "one to many" model. with,has,wherehas