//https://csprograms4u.blogspot.com/
//Chapter 1
//Program 1
//Arithmetic Operators
import
java.util.Scanner;
public
class AO
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
//variable
declaration
float a,b,sum,diff,pro,div;
System.out.println("Enter two
values");
a=sc.nextFloat();
b=sc.nextFloat();
sum=a+b;
diff=a-b;
pro=a*b;
System.out.println("Sum="+sum);
System.out.println("Difference="+diff);
System.out.println("Product="+pro);
//Division
by zero is controlled using if else block
if(b==0)
{
System.out.println("Division
by Zero is Not Possible");
}
else
{
div=a/b;
System.out.println("Division="+div);
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.