Advertisement
Guest User

Untitled

a guest
May 6th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 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.  
  7. package offline;
  8. import java.util.Scanner;
  9. /**
  10. *
  11. * @author User
  12. */
  13. public class Offline {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) {
  19. // TODO code application logic here
  20. Scanner scn=new Scanner(System.in);
  21. int c;
  22. c = scn.nextInt();
  23. for(int j=0;j<c;j++)
  24. {
  25.  
  26. String s=scn.next();
  27. // int n=scn.nextInt();
  28.  
  29. char a[]=new char[s.length()];
  30. a=s.toCharArray();
  31. int b[]=new int[20];
  32. int track=0;
  33. for(int g=0;g<s.length();g++)
  34. {
  35. if(Character.isWhitespace(a[g]))
  36. {
  37. track=track+(++g);
  38. }
  39. }
  40.  
  41. String s1=new String(s.substring(track,s.length()-1));//)
  42. int n=Integer.parseInt(s1);
  43. int count=0;
  44. for(int i=0;i<s.length();i++)
  45. {
  46. if(Character.isDigit(a[i]))
  47. {
  48. int m=Character.getNumericValue(a[i]);
  49. b[count]=m;
  50. count++;
  51. }
  52. }
  53. int code=(b[0]*10+b[1])*(b[2]*10+b[3])*(b[4]*10+b[5]);
  54. if(code==n)
  55. {
  56. System.out.println("case"+j+":-"+"VALID");
  57. }
  58. else
  59. {
  60. System.out.println("case"+j+":-"+"invalid");
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement