Guest User

Untitled

a guest
Jun 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. class Operations{
  6. //TODO
  7. public Operations(int n1,int n2)
  8. {
  9. int num1 = n1;
  10. int num2 = n2;
  11. int add = num1 + num2;
  12. int sub = num1 - num2;
  13. }
  14. public static int multiply()
  15. {
  16. int mul = add * sub;
  17. System.out.printf("The final value is %d", +mul);
  18. }
  19. }
  20.  
  21. public class Source {
  22. public static void main(String[] args) throws IOException {
  23. /*Scan input numbers (using buffered reader), call constructor of Operations class and then call multiply*/
  24. InputStreamReader r=new InputStreamReader(System.in);
  25. BufferedReader br=new BufferedReader(r);
  26. System.out.println("Enter first num");
  27. int num1=br.readInt();
  28. System.out.println("Enter second num");
  29. int num2=br.readInt();
  30. Operations mult = new Operations(num1, num2);
  31. mult.multiply();
  32. }
  33. }
  34.  
  35. class Operations{
  36. int add,sub;
  37. public Operations(int n1,int n2){
  38. int num1 = n1;
  39. int num2 = n2;
  40. add = num1 + num2;
  41. sub = num1 - num2;
  42. }
  43. public void multiply(){
  44. int mul = add * sub;
  45. System.out.printf("The final value is %d", +mul);
  46. }
  47. }
  48.  
  49. int num1=br.readInt();
  50.  
  51. int num1 = Integer.parseInt(br.readLine());
Add Comment
Please, Sign In to add comment