Modulus and OpEquals Example - Class Work

This for Modulus example

// Demonstrate the % operator.

class Modulus {
  public static void main( String args []) {
 int x = 42;
 double y = 42.3;
        System.out.println("x mod 10 =" + x % 10);
  System.out.println( "y mod 10 =" + y % 10);
      } 
 }
 

This is for OpEquals Example

class OpEquals { // Demonstate several assignment operators.
  public static void main( String args []) {
 int a = 1, b = 2, c = 3;

 a+=5; b*=4; c+= a*b; c%=6;
        System.out.println("a =" + a); // a=1+5 = 6
  System.out.println("b =" + b); // b=2*4=8
  System.out.println("c =" + c); // c = 3+ (6*8)=51=> c%6 = 51%6=3
      } 
 }
 

This is class Room example

class  room
{
 public static void main(String[] args) 
 {
  int length=15;
  int width=25;
  int area = 375;
  System.out.println("The floor space is " + area +  " square feet");

 }
}
 

This interest Class example

class  interest
{
 public static void main(String[] args) 
 {
  double invested = 1000;
  double rate=0.05;
  double time=1;
  System.out.println("Future Amount" + invested * rate * time);
 }
}

Java Tips

See also
Java Boolean Logical Operators

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.