Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 offline;
- import java.util.Scanner;
- /**
- *
- * @author User
- */
- public class Offline {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner scn=new Scanner(System.in);
- int c;
- c = scn.nextInt();
- for(int j=0;j<c;j++)
- {
- String s=scn.next();
- // int n=scn.nextInt();
- char a[]=new char[s.length()];
- a=s.toCharArray();
- int b[]=new int[20];
- int track=0;
- for(int g=0;g<s.length();g++)
- {
- if(Character.isWhitespace(a[g]))
- {
- track=track+(++g);
- }
- }
- String s1=new String(s.substring(track,s.length()-1));//)
- int n=Integer.parseInt(s1);
- int count=0;
- for(int i=0;i<s.length();i++)
- {
- if(Character.isDigit(a[i]))
- {
- int m=Character.getNumericValue(a[i]);
- b[count]=m;
- count++;
- }
- }
- int code=(b[0]*10+b[1])*(b[2]*10+b[3])*(b[4]*10+b[5]);
- if(code==n)
- {
- System.out.println("case"+j+":-"+"VALID");
- }
- else
- {
- System.out.println("case"+j+":-"+"invalid");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement