package com.company;
import java.util.Scanner;
public class Program37 {
static int sum(int a, int b)
{
int sum;
sum=a+b;
return sum;
}
static int sub(int a, int b)
{
int sub;
sub=a-b;
return sub;
}
static float div(int a, int b)
{
int div;
div=a/b;
return div;
}
static int mul(int a, int b)
{
int mul;
mul=a*b;
return mul;
}
public static void main(String[] args) {
Scanner p = new Scanner(System.in);
System.out.println("please enter a first number:");
int x=p.nextInt();
System.out.println("please enter a second number:");
int y=p.nextInt();
int c;
c=sum(x, y);
System.out.println("sum is");
System.out.println(c);
System.out.println("sub is");
System.out.println(sub(x,y));
System.out.println("div is");
System.out.println(div(x,y));
System.out.println("mul is");
System.out.println(mul(x,y));
}
}
Hi Friends ! You are on HR Developers website. Here you can find the codes of different languages like c ,c++ , java, pyton and many other languages.
Saturday, June 26, 2021
making a simple calculator using functions (Java) (200)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment