Sum Product Four Numbers coderinme

Sum Product Four Numbers coderinme

Finding the sum/product of four numbers entered by the user manually would be very hectic, frustrating as well as a time taking process. To make it simple Let us now write a program in Java that reads four integers from the user in the main program. It passes these two integers and then finds the sum of all these integers by adding the four and returns the sum/product as an output.
Given any two numbers like a and b
sum = a + b
product = a * b
Write a Java Program which prompts the user to enter 4 numbers. The program will then computes and display their sum and their product.

public class Q16 
public static void main(String[] args) throws IOException 
BufferedReader inp=new BufferedReader(new InputStreamReader(;
System.out.println("Enter any 4 number :");
double n1=Double.parseDouble(inp.readLine());
double n2=Double.parseDouble(inp.readLine());
double n3=Double.parseDouble(inp.readLine());
double n4=Double.parseDouble(inp.readLine());
System.out.println("The sum of 4 number is : "+(n1+n2+n3+n4));
System.out.println("The product of 4 number is : "+(n1*n2*n3*n4));

For more programs on Java, visit our Java Archives

Sum Product

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.