Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- /*
- Amon Guinan
- Friday, January 25.
- Program checks whether HTML sequences have equal amounts of < and >.
- */
- public class exercises {
- public static void main(String[] args) {
- System.out.println("Input an HTML sequence.");
- Scanner input = new Scanner(System.in);
- String URL = input.nextLine();
- int x = 0;
- int y = 0;
- while(URL.indexOf("<") != -1){
- URL = URL.replaceFirst("<","_");
- x = x+1;
- }
- while(URL.indexOf(">") != -1){
- URL = URL.replaceFirst(">","_");
- y = y+1;
- }
- while(URL.indexOf(">") != -1);
- if(x!=y)
- {
- System.out.print("Invalid URL.");
- }
- else
- {
- System.out.print("Valid URL.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement