lesson 2 math operations Using Java Netbeans IDE 8.2 Featuring the Scanner input Reader





package firstprograms;


import java.util.Scanner ;
import java.io.*;

public class MathBasic {
  public static void main(String args[])
  {
    Scanner in=new Scanner (System.in).useDelimiter("\n"); //Class needed to use scanner input reader
    //list of variables to store 2 input numbers
     float n1,n2 ;
    // list of variables to store computer values
     double sum, diff,quotient,product;
    
     //input first numbers ;
     System.out.print("Ënter first number : ");
      //read and store input number
      n1=in.nextInt();
     
     //input second numbers ;
     System.out.print("Ënter second number :");
      //read and store input number
      n2=in.nextInt();
     
     //compute and store the sum  of n1 and n2 , by adding n1 and n2
     sum =n1+n2;
     //Display the computed sum to display the result of computation
     System.out.println(" Sum " +sum);
    
    //compute and store the difference , by subtracting n1 and n2
     diff =n1 - n2;
     //Display the computed difference to display the result of computation
     System.out.println(" Difference "  +diff);
    
      quotient =n1/n2;
     //Display the computed quotient to display the result of computation
     System.out.println(" Quotient " +quotient);
    
    //compute and store the product , by subtracting n1 and n2
      product=n1 * n2;
     //Display the computed product to display the result of computation
     System.out.println(" Product "  +product);
    
  }
}


package firstprograms;

import java.util.Scanner ;
import java.io.*;

public class MathBasic {
  public static void main(String args[])
  {
    Scanner in=new Scanner (System.in).useDelimiter("\n"); //Class needed to use scanner input reader
    //list of variables to store 2 input numbers
     float n1,n2 ;
    // list of variables to store computer values
     double sum, diff,quotient,product;
    
     //input first numbers ;
     System.out.print("Ënter first number : ");
      //read and store input number
      n1=in.nextInt();
     
     //input second numbers ;
     System.out.print("Ënter second number :");
      //read and store input number
      n2=in.nextInt();
     
     //compute and store the sum  of n1 and n2 , by adding n1 and n2
     sum =n1+n2;
     //Display the computed sum to display the result of computation
     System.out.println(" Sum " +sum);
    
    //compute and store the difference , by subtracting n1 and n2
     diff =n1 - n2;
     //Display the computed difference to display the result of computation
     System.out.println(" Difference "  +diff);
    
      quotient =n1/n2;
     //Display the computed quotient to display the result of computation
     System.out.println(" Quotient " +quotient);
    
    //compute and store the product , by subtracting n1 and n2
      product=n1 * n2;
     //Display the computed product to display the result of computation
     System.out.println(" Product "  +product);
    
  }
}

Comments

Popular posts from this blog

Lesson 4 If Else If Condition statement to Compute Scholarship discount using Relational Operators Sample Program Explained

Exercise HTML Basics