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);
//
}
}
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
Post a Comment