Java #30:One way to Perform Calculations Across Functions in java

       //Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: Performing calculations between functions


* @author Akin

public class DagbaComputerSample {

* @param args the command line arguments

public static int addNumbers(int x)//Function add
int d = x + 1;//int to store the value of adding to x
return d;
}//end of addNumbers

public static int multiplyNumbers (int multiplyMe)//Function to multiply
//Creating a new int to hold the value of multiplyMe multiplied by 10
int e = multiplyMe * 10;
return e;//sending e back

public static int divideNumbers (int divideMe)//Funcion to divide
int f = divideMe/2; //Dividing variable from Main and storing it in f
return f; // Sending f back to main
}//end of divideNumbers

public static void main(String[] args)
//Creating the int, I’ll be adding across functions
int x = 5;

//Printing out x to check it works
System.out.println(“x = “+ x);

//printing out the result after the addNumbers Function
System.out.println(“After going to the addNumbersFunction number = ” +addNumbers(x));

//Creating a new int to hold the value from the addNumbers Function
int multiplyMe = addNumbers(x);

//Sending multiplyMe to the multipyNumbers function
System.out.println(“After going to the multiplyNumbers function = ” + multiplyNumbers(multiplyMe) );

//Creating an int to hold the new value of x before I divide it
int divideMe = multiplyNumbers(multiplyMe);

//Sending Number to get divided and then printing
System.out.println(“After dividing the value is now = ” + divideNumbers(divideMe));

}//end of main class
}//end of DagbaComputerSample Class

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: