Write a
program in Java that will ask the user to input three numbers and then the
program will find the total sum of three numbers given by our user.
My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com
Program Listing
addition_of_three_numbers.java
/**
* @author Jake Rodriguez Pomperada,MAED-IT, MIT
* www.jakerpomperada.com www.jakerpompomperada.blogspot.com
* jakerpomperada@gmail.com
* Bacolod City, Negros Occidental Philippines
*
*/
import java.util.Scanner;
public class addition_of_three_numbers {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println();
System.out.println("===== Addition of Three Numbers in Java =====");
System.out.println();
System.out.print("Enter First Number : ");
int a = scan.nextInt();
System.out.print("Enter Second Number : ");
int b = scan.nextInt();
System.out.print("Enter Third Number : ");
int c = scan.nextInt();
int sum = (a+b+c);
System.out.println();
System.out.print("The sum of "+ a + " , " + b + " and "
+ c + " is " + sum + ".");
System.out.println("\n\n");
System.out.println("===== END OF PROGRAM =====");
System.out.println();
}
}
No comments:
Post a Comment