Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 62.
- package com.Suarez;
- /*
- Xander Fermier
- 1/25/19
- Checks if the entered email adress is valid
- */
- import java.util.*;
- import java.lang.*;
- public class EmailAddressValidator {
- public static void main(String []args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("Give me an email address to check");
- String input = scan.next();
- int inputLength = input.length();
- int atCheck = 0;
- for (int i = 0; i <= inputLength-1; i++)
- {
- char inputchar = input.charAt(i);
- String atSymbol = String.valueOf(inputchar);
- if (atSymbol == "@")
- {
- atCheck++;
- }
- atSymbol = "";
- }
- if (atCheck == 1)
- {
- System.out.println("The email address is valid.");
- }
- else
- {
- System.out.println("The email address is not valid.");
- }
- }
- }
- 64.
- package com.Suarez;
- /*
- Xander Fermier
- 1/25/19
- covnerts the users. entered decimal value to binary
- */
- import java.util.*;
- public class UserDecimalToBinary {
- public static void main(String []args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("Give me your number to convert.");
- String input = scan.next();
- System.out.println(Integer.parseInt(input, 2));
- }
- }
- 66.
- package com.Suarez;
- /*
- Xander fermier
- 1/25/19
- this program simulates XOR
- */
- import java.util.*;
- public class XORSimulator {
- public static void main(String[]args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("Give me a XOR to check");
- String input = scan.next();
- char first;
- char second;
- String truth = "10";
- String falseth = "11";
- String truth2 = "01";
- String falseth2 = "00";
- int inputLength = input.length();
- StringBuilder check= new StringBuilder();
- for (int i = 0; i <= inputLength; i+=2)
- {
- first = input.charAt(i);
- second = input.charAt(i+1);
- check.append(first);
- check.append(second);
- }
- if (check.equals(truth) || check.equals(truth2))
- {
- System.out.println("True");
- }
- else if( check.equals(falseth) || check.equals(falseth2))
- {
- System.out.println("False");
- }
- else
- {
- System.out.println("Invalid entry");
- }
- }
- }
- 68.
- package com.Suarez;
- /*
- xander Fermier
- 1/25/19
- this program checks whether the entered HTML is valid based on whether or not it has the same amount of <>
- */
- import java.util.*;
- public class HTMLChecker {
- public static void main(String []args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("Give me your line to check");
- String input = scan.nextLine();
- int inputLength = input.length()-1;
- int openBracket = 0;
- int closeBracket = 0;
- for (int i = 0; i <= inputLength; i++)
- {
- char inputChar = input.charAt(i);
- String bracket = String.valueOf(inputChar);
- if (bracket == "<")
- {
- openBracket++;
- }
- if (bracket == ">")
- {
- closeBracket++;
- }
- bracket = "";
- }
- if (openBracket == closeBracket)
- {
- System.out.println("Your HTML is valid.");
- }
- else
- {
- System.out.println("Your HTML is not valid.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement