Assignemnt #17

Code

  /// Name: Daniel Nguyen
  /// Period: 6
  /// Program Name: MathOperations Program
  /// File Name: MathOperations.java
  /// Date Finished: 9/22/2015
  // when using decimals use double for text use String and for whole numbers or letters use int
public class MathOperations {
    public static void main( String[] args ) {
        
        int a, b, c, d, e, f, g;
        double x, y, z;
        String one, two, both;
        // int
        a = 10;
        b = 27;
        System.out.println( "a is " + a + ", b is " + b );
        c = a + b;
        System.out.println( "a+b is " + c );
         d = a - b;
        System.out.println( "a-b is " + d );
         e = a+b*3;
         System.out.println( "a+b*3 is " + e );
         f = b / 2;
         System.out.println( "b/2 is " + f );
         g = b % 10;
         System.out.println( "b%10 is " + g );
 
         x = 1.1;
         System.out.println( "\nx is " + x );
         y = x*x;
         System.out.println( "x*x is " + y );
         z = b / 2;
         System.out.println( "b/2 is " + z );
         System.out.println();
 
         one = "dog";
         two = "house";
         both = one + two;
         System.out.println( both );
     }
 }
    

Picture of the output

Assignment 3
BACK HOME NEXT