At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
Sagot :
The question states that we have to write a code in java, that adds two numbers num1 and num2 and then divide the sum by 3. Store the result of the calculation in the variable named finalresult.
This program can be coded in any programming languages such as C, C++, C#, and Java. But as given in the question, it is required to write it in Java programming language. Java is a high level programming language that is used to develop applications and programs.
The code is given below what is required in the question.
public class MyClass {
public static void main(String args[]) {
int num1;// declared variable num1
int num2;//declared variable num2
float finalresult;//declared variable finalresult which store the result
num1 = 4;//assigned value to num1
num2 = 5;//assigned value to num2
finalresult = (num1 + num2)/3;/* calculation performed and result stored in variable finalresult*/
System.out.println("Sum of " +num1+" and " + num2+ " is " + finalresult);//output display
}
}
You can learn more about how to sum numbers in java at
https://brainly.com/question/24412452
#SPJ4
We hope this information was helpful. Feel free to return anytime for more answers to your questions and concerns. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for using Westonci.ca. Come back for more in-depth answers to all your queries.