How To Create A Java Program That Will Create The Sum, Product And Average Of 3 Numbers;3,4 And 5?
Create a java program that will displays the sum, product and average of three numbers. Let the num 1=3, num2=4 and num3=5.
1 Answer - Sort by: Date | Rating
Public static void main() {
// declare variables
int num1, num2, num3;
int sum, product;
double avg;
// Variables initial values
num1 = 3;
num2 = 4;
num3 = 5;
// calculate sum, product, and average
sum = (num1 + num2 + num3);
product = (num1 * num2 * num3);
avg = sum/3;
// print
System.out.print("Sum = " + sum);
System.out.print("Product = " + product);
System.out.print("Average = " + avg);
}
Hope this is what you want
// declare variables
int num1, num2, num3;
int sum, product;
double avg;
// Variables initial values
num1 = 3;
num2 = 4;
num3 = 5;
// calculate sum, product, and average
sum = (num1 + num2 + num3);
product = (num1 * num2 * num3);
avg = sum/3;
System.out.print("Sum = " + sum);
System.out.print("Product = " + product);
System.out.print("Average = " + avg);
}
Hope this is what you want
1
0
- What Is An Attribute In Java?
- Why Do We Use Public Static Void Main In Java?
- Do I Have To Write A Main Method In Every Class I Create?Why?
- Do I Have To Write A Main Method In Every Class I Create?
- What How The Step For Make Library Management?
- In Which Process We Can Start Java?
- Define The Concept Of Java Byte Code?
- How To Run Remote Method Invocation In More Machine?
- How To Run Java Remote Method Invocation In More Machine?
- How To Make A Java Program That Will Ask The User To Input A Number And Display All The Even Number And The Sum Of All Even Numbers Based On The Inputted/ Given Numbers?
- Is A Static Variable An Instance?
- How To Compile And Run Java Package?
- What Does Literati-on Mean?
- What Is Abstract Class In Details?
- What Is Meant By Remote Method Invocation In Java?
- What Is Meant By Package In Java?
- What Is Meant By Servlet In Java?
- When Was Java Released?
- What Is Latest Technologies In Java?
- Write A Program Using Do…..while Loop To Calculate And Print The First M Fibonacci Numbers?
- What Is The Difference Between Reference &instance Variable?
- Why Java Is Slow?
- What Is The Drawback Of Ms Access?
- What Is Replaced In Place Of Pointers In Java?
- What Replaces Pointers In Java?

New Comment - Comments are editable for 5 min.