Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Learning Code Examples

Simple Arithmetic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Simple Arithmetic package com.ack.learning; public class SimpleArithmetic { public static void main( String[] args ) { int withdraw = 300; int deposit = 400; // declare and define using initialised variables int balance = deposit - withdraw; // different way of adding 100 to balance balance = balance + 100; balance += 100; // use boolean boolean isGood = false; isGood = !isGood; // isGood is now true // remainder is one int remainder = 100 % 3; // all operators have the <operator>= semantics // so we have examles of /= and *= below int value = 100 * 10; value /= 5; value *= 2; // and of course we can have compound arithmetic int yourValue = ( ( value + balance ) / ( withdraw * deposit ) ); } }