args - Methods/functions in Java -


Guidelines were given with the code given to me: Java allows us to use methods / functions so that we can store the processes we can use. More than once, so I want to update your code where the normal tasks are done, it can be done in any method / function. Any idea how to do this? Package's fifth assignment; Public class arithmetic {public static zero main (string [] args) {// variable first number and second number int length = args.length; If (length! = 3) {System.out.println ("You seem to enter an int, int then, +, - sign an operation like x or /."); Return; } Int firstNumber = integer.parissant (args [0]); Int secondNumber = integer Paracet (Argos [1]); Int extra = first number + second number; Int minus = firstNumber - secondNumber; Int division = firstNumber / secondNumber; Int times = first number * second number; String arithmetic = args [2]; If (arithmetic.quilues ("+")} {System.out.println (Args [0] + + + Arg +2 + + + Arg + 1 + + "=" + Extra);} And if (Arithmetic .exls ("-"}} {System.out.println (Args [0] + + + Args [2] + "+ + Argus [1] +" = "+ 0);} And if (arithmetic.quilues ( "/")) {System.out.println (Args [0] + + + [2] + + + + + [Arg] [1] + "=" + Partition); // I " Could not be used because he was looking to pull down all the // files related to this program. In this case I changed the "" "" x "to change the" x "so that I can get the solution that you were looking for.} And if (arithmetic.exe (" x ") {System .out.println (Argos [0] + + + Argus [2] + "+ + Argus [1] +" = "+ times);} // After printing the following console / what is the length of each argument / System.out.println (args [0] + "length of" + args [0] is the length ()); System.out.println (args [1] + "length" + args [1]. Length ()); If (arithmetic.exls ("+") {int total = String.valueOf (Additional) .length (); System.out.println (additional + "length" + total) is; } And if (arithmetic. Par ("-")) {int total = String.valueOf (zero) Length (); System.out.println (zero + "length" + total) is; } And if (arithmetic.exls ("/")) {int total = String.valueOf (partition) .length (); System.out.println (partition + "length" + total) is; } And if (arithmetic is equal to ("x") {int total = String.valueOf (multiplied). Length (); System.out.println (multiplication + "length of +" + total) is; }}}

I will provide a unique example, but you should do it yourself Of

You have it in your code:

  System.out.println (additional + "length" + total); Instead, you can probably create a method that will work with two entities:  
  public zero print status (int check, int Lat) {System.out.println (Czech + "length" + length); }   

will be allowed to call you

  printStatus (additional, total);   

This is just a difficult example, but you can wrap the "process" of the code in a method, and for this pass the necessary standards to execute the method.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -