how write a program in java to generate the sum of three given numbers in java?
step 1. import scanner package to input and output data processing
step 2.declare any three variable and their data types
step 3.calucate the sum of variable
step 4.print the output at screen.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.internationalyouthauity;
/**
*
* @author rajesh shukla
*/
import java.util.Scanner;
public class sumofthreenumber {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n1,n2,n3,sum;
System.out.println("Enter the value of n1");
n1=sc.nextInt();
System.out.println("Enter the value of n2");
n2=sc.nextInt();
System.out.println("Enter the value of n3");
n3=sc.nextInt();
sum=n1+n2+n3;
System.out.println("sum of three given number n1,n2,n3 are="+sum);
}
}
0 comments:
Post a Comment