Help on Java homework?
So recommendations what I’ve truly written so far and it isn’t working.How could i complete this program so the good news is result.I want to be able to add (+) a pair of values plus see a result.Thanks
public class Addition
public static avoid main(String args)
int a = Integer.parseInt(args0);
int b = Integer.parseInt(args1);
// Results
There is actually nothing wrong in your program with the exception of that there isn’t any output affirmation:
Add the examples below code listed below //Result, and you may get the actual output.
Method.out.println( “Result = ” + (a + b) );
/* Employing of additional brackets above like (a + b) is must or the aspects a and b are going to be treated as string in the course of output and you may get “46” as result.*/
// Practice:
javac Accessory.java
java Addition 4 6
result:Result = 10
#Please note:
You must check the actual if length of the args number is 2, otherwise should the user does not enter COUPLE OF args for the command brand an exclusion gets chucked.
declare this Variable first
and use Sestym…..
or perhaps no end result.
Leave a Reply
You must be logged in to post a comment.