Design ideas
It is important not to say much more than to build the most basic Java creation and then throw an exception handler to detect the user's input. Then you have to enter the work, needless to say, the online tutorial has a scanner input method, we introduce a little bit.
Finally, the user input string to determine the number of times an addition cycle, and in the final output.
Flow chart:
Program
ImportJava.io.*;ImportJava.util.Scanner; Public classShuru {/** * @paramargs*/ Public Static voidMain (string[] args)throwsioexception{//TODO auto-generated Method StubSystem.out.println ("Please enter a number"); Scanner SC=NewScanner (system.in);//Console InputString Input=Sc.nextline (); System.out.println ("You have entered" +input); Input=Input.trim (); String[]temp=input.split (""); Double[]nums=New Double[Temp.length];//character Length Doubleaaa=0;//Store SumSystem.out.println ("The result is"); for(inti=0;i<temp.length;i++) {Nums[i]=double.parsedouble (Temp[i]); if(i==0) System.out.print (Nums[i]); Else if(nums[i]>0) System.out.print ("+"+Nums[i]); Else if(nums[i]<0) System.out.print (Nums[i]); ElseSystem.out.print ("+" +Nums[i]); AAA+=Nums[i]; } System.out.print ("="+AAA); }}
Run
Getting Started with Java transforms