Sum of Numbers coderinme

Sum of Numbers coderinme

Sum of Numbers coderinme
Finding the sum of two 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 two 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 two and returns the sum as an output. Finally the sum is printed.

What we are supposed to do here is very simple. Assuming that the first number is 5 and the second number is 8, then the required output is 5 + 8 = 13

Write a Java program to calculate sum of two numbers.

import java.io.*;
public class Q1
{
public static void main(String[] args) throws IOException
{
BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
float a,b;
System.out.print("Enter First number: ");
a = Float.parseFloat(inp.readLine());
System.out.print("Enter Second number: ");
b = Float.parseFloat(inp.readLine());
System.out.println("Sum of the two number is: "+(a+b));
}
}

For more programs on Java, visit our Java Archives

Sum of Numbers coderinme

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.