Advertisement
wadkat

java even and odd

Nov 2nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package switchcase;
  7. import java.util.Scanner;
  8.  
  9. /**
  10. *
  11. * @author pclab
  12. */
  13. public class q3 {
  14. public static void main(String[] args){
  15. Scanner keyboard=new Scanner(System.in);
  16. int no1, no2;
  17. System.out.println("Input integer: ");
  18. no1=keyboard.nextInt();
  19. if (no1%2==1)
  20. {
  21. no2=(no1*2)-3;
  22. System.out.println("The answer is "+no2);
  23. }
  24. else
  25. if(no1%2==0)
  26. {
  27. no2=(no1*3)-5;
  28. System.out.println("The answer is "+no2);
  29. }
  30. else
  31. System.out.println("Invalid input");
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement