Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- class Operations{
- //TODO
- public Operations(int n1,int n2)
- {
- int num1 = n1;
- int num2 = n2;
- int add = num1 + num2;
- int sub = num1 - num2;
- }
- public static int multiply()
- {
- int mul = add * sub;
- System.out.printf("The final value is %d", +mul);
- }
- }
- public class Source {
- public static void main(String[] args) throws IOException {
- /*Scan input numbers (using buffered reader), call constructor of Operations class and then call multiply*/
- InputStreamReader r=new InputStreamReader(System.in);
- BufferedReader br=new BufferedReader(r);
- System.out.println("Enter first num");
- int num1=br.readInt();
- System.out.println("Enter second num");
- int num2=br.readInt();
- Operations mult = new Operations(num1, num2);
- mult.multiply();
- }
- }
- class Operations{
- int add,sub;
- public Operations(int n1,int n2){
- int num1 = n1;
- int num2 = n2;
- add = num1 + num2;
- sub = num1 - num2;
- }
- public void multiply(){
- int mul = add * sub;
- System.out.printf("The final value is %d", +mul);
- }
- }
- int num1=br.readInt();
- int num1 = Integer.parseInt(br.readLine());
Add Comment
Please, Sign In to add comment