Skip to main content

Create number for sum , divide , subtract , multiplied , residue that use in Boxes and No Boxes in Java

//For Boxes

import javax.swing.JOptionPane;

   public class LAB2 {     
    public static void main(String[] args) {
       
        String firstnumber , secondnumber  ;
        int a , b , sum , divide , subtract , multiplied , residue;
                                             
        firstnumber  = JOptionPane.showInputDialog(null,"Enter firstnumber:");
        secondnumber = JOptionPane.showInputDialog(null,"Enter secondnumber:");
        a = Integer.parseInt(firstnumber);
        b = Integer.parseInt(secondnumber);
       
sum = a + b;
divide = a / b;
subtract = a - b;
multiplied = a * b;
 residue = a % b;
JOptionPane.showMessageDialog(null, "\t Sum =" +sum+ "\n divide =" +divide+ "\n subtract =" +subtract+ "\n multiplied =" +multiplied+ "\n residue =" +residue);
       
    
    }
   
}

//For No Boxes

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package teedculculator;
/**   @author HOANG LIHUO     */
import java.util.Scanner;
public class TeedCulculator {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      // 2.create variable A and B
        double a , b , sum , divide , subtract , multiplied , remainder;
        Scanner input = new Scanner(System.in);
        System.out.print("a = ");
                 a = input.nextDouble();
        System.out.print("b = "); 
                 b = input.nextDouble();
      // 3. Do the following Operations     
           // a. Sum A + B
          
                sum = a + b;
        System.out.println("a. A + B =" +sum);
       
           // b. Divide A / B
          
                divide = a / b;
        System.out.println("b. A / B =" +divide);
       
           // c. Subtract A - B
          
                subtract = a - b;
        System.out.println("c. A - B =" +subtract);
       
           // d. Multiplied A*B
          
                multiplied= a * b;
        System.out.println("d. A * B =" +multiplied);
       
           // e. Remainder A % B
          
                remainder = a % b;
        System.out.println("e. A % B =" +remainder);
       
      //
     
    } 
}

Comments

Popular posts from this blog

The laws of set algebra & Laws derivable >> in the table 5.1 & 5.2 :

Ans :       Commutative laws                             Ans:          Associative laws Ans:         Distributive laws       Ans:            Identity laws Ans:         Complement laws Ans:          Absorption laws Ans:         Minimization laws Ans:         De Morgan’s laws

Exercise Chapter7 : Vectors

VECTORS AND SCALARS: BASIC CONCEPTS Exercise 7.2 Solution : 1. For the arbitrary points A, B, C, D and E, and a single  vector which is equivalent to A:   DC + CB    = DB B:  CE + DC   = DE 2.  shows a cube. Let p =  AB, q =  AD and  r =  AE . Express the vectors representing  BD,  AC and  AG in terms of p, q and r. Consider the triangle ABD shown in Figure. We note that  BD represents the third  side of the triangle formed when AD are placed head to tail. Using the triangle law we find :                      AB + BD = AD               => BD = AD - AB                             = q - p Consider the triangle  ADC  shown in Figure. We note that  AD  represe...

Matrix algebra

                 Matrices provide a means of storing large quantities of information in such a way that each piece can be easily identified and manipulated. They permit the solution of large systems of linear equations to be carried out in a logical and formal way so that computer implementation follows naturally. Applications of matrices extend over many areas of engineering including electrical network analysis and robotics. 1-BASIC DEFINITIONS                  Matrix is a rectangular pattern or array of numbers.      For example:                    are all matrices. Note that we usually use a capital letter to denote a matrix, and enclose the array of numbers in brackets. To describe the size of a matrix we quote its number of rows and columns in that order so, for example, an r × s matrix has r rows and s colu...