8:20 pm - Saturday April 20, 2019

Java program for Basic Add,Sub,Mul and Division

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044


*@author :CandidJava.com

*@descriptions : This program explain how to display the Addition,subtraction,multiplication and division values using for loop


import java.util.*;

class Add{

public static void main(String args[]){

//Assign the values for a & b. c is used to store addition of two values.

int a=5,b=3,c;

c=a+b; // add the values of a & b

System.out.println("the values is= "+c); // display the output which is stored in c

//Assign the values for k & l. m is used to store subtraction of two values.

int k=12,l=10,m;

m=k-l; // sub the values of k & l

System.out.println("the values is= "+ m); // display the output which is stored in m

//Assign the values for p & r. s is used to store multiplication of two values.

int p=10,r=20,s;

s=p*r; // multiply the values of p & r

System.out.println( "the values is= "+s); // display the output which is stored in s

//Assign the values for x & y. z is used to store division of two values.

int x=100,y=50,z;

z=x/y; // Divide the values of p & r

System.out.println("the values is= "+ z); // display the output which is stored in z




D:\ code>java >javac Add.java

D:\ code>java >java Add

The values is= 8

The values is= 2

The values is= 200

The values is= 2


Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply