Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
Java Program For Addition, Subtraction, Multiplication, Division | Programs
Latest :

Java Program For Addition, Subtraction, Multiplication, Division | Programs

Java program for Addition, Subtraction, Multiplication and Division. Here we will discuss the most common mathematical operations such as addition, subtraction, multiplication and division In java. The compiler has been added as well so that you can execute the programs yourself, along with suitable examples and sample outputs. The programs as aforementioned are:

  • Addition.
  • Addition using Static Method.
  • Subtraction.
  • Multiplication.
  • Multiplication without using the Multiplication(*) operator.
  • Division.
  • Division without using the Division (/) operator.

Java Program – Addition

1) We are using the standard formula for adding two numbers.c=a+b.

2) Read the values using scanner object sc.nextInt() and store these values in the variables a,b and calculate addition of a,b and print the c value.

Addition(Using Static Method)

1) addition(int x, int y) is the static method, which calculates the addition of two numbers and returns the value.

2) addition(a,b) method calls at the main method then that static method calculates the addition of two numbers and returns the value and value will be assigned to the variable c.

Subtraction Java Program

1) We are using the formula for subtraction is c=a-b.

2) Read the values using scanner object sc.nextInt() and store these values in the variables a,b. Subtract the smaller value from bigger value and result will be assigned to c and print the c value.

Java Multiplication Program

1) The formula for multiplication of two numbers is c=a*b.

2) Read the values using scanner object sc.nextInt() and store these values in the variables x,y and calculate multiplication of these numbers then print the z value.

Multiplication of two numbers without using the Multiplication(*) operator

1) We are calculating the multiplication of two numbers without using “*” operator.

2) Read the values using scanner object sc.nextInt() and store these values in the variables x,y.

3) If the condition at while x!=0 is true then z=(z+y) and x value decreased by 1, repeats until x!=0. If x=0 then while loop terminates then print the z value.

Division

1) The standard formula for division of two numbers is  c=a/b where b!=0.

2) Read the numerator and denominator values using scanner object sc.nextInt() and store these values in the variables n,d and calculate the division of these numbers then print the “res” value.

Division of two numbers without using the Division(/) operator

1) We are calculating the division of two numbers without using the “/” operator.

2) Read the numerator and denominator values using scanner object sc.nextInt()  and store these values in the variables a,b. if b!=0 then a=a-b, and c value increased by 1 until  the condition at  while a>=b is false.After all the iterations, it prints the c value.

More Java Programs:

x

Check Also

Java Program Count Vowels In A String | Programs

Java Program to count vowels in a string – Here, we discuss the various methods ...

atakoy escortatakoy escortbakırköy escorthalkali escortbağcılar escortsightcaredeneme bonusu veren siteleristanbul, escortromabetdeneme bonusu veren sitelerdeneme bonusu veren sitelerkulisbetDeneme Bonusu Veren Sitelercasino siteleriDeneme Bonusu Veren SitelerAlanya EscortDeneme Bonusu Veren Sitelerpadişahbetgrandpashabettaraftarium24grandpashabetgrandpashabetgrandpashabetGrandpashabetgrandpashabetgrandpashabetGrandpashabetsahabetbetnanodeneme bonusu veren sitelerdeneme bonusu veren sitelerSelçuksportsbetcioiptv satın almavibetextrabetiptvbetciomatbetcasibomMeritkingbetciokralbetsamsun escortcasibomcasibom girişcasibom girişcasibomcasibomjojobet girişTuz lambaZbahisZbahis GirişOtobetOtobet GirişBetcioBetcio Girişcasibom girişcasibomyalova escortBetturkeyBetturkey Girişmeritkingcasibombetwoonmeritkingescort antalyabahcesehir masaj salonucasibom güncel girişcasibomcasibom girişcasibomcasibom girişcasibom güncel girişjojobetmarsbahismarsbahis giriştimebettimebetgrandbettinggrandbetting giriştaraftarium24padişahbetgrandpashabetlidyabet girişcasibomMarsbahiskralbetcasibomGrandpashabetGrandpashabet girişGRANDPASHABETroyalbetcasinofastPalacebetramadabetgrandpashabetgrandpashabetmeritkingmeritkinggrandpashabettipicotr girişcasibom girişcasibomcasibombetexperextrabetslotbarslotbar girişbetparkbetpark girişpadişahbetpadişahbet giriştarafbettimebettipobetmeritking girişjojobet girişmatbet girişmegabahis girişextrabet,extrabet giriştempobet girişbetpark girişbetboo girişsafirbet girişmegabahisextrabettempobetbetparkbetboosafirbetrestbetsavoybettingmaksibetsekabetrestbet girişsavoybetting girişsekabet girişcasibom