Introduction to Java Programming编程题9.1<检查SSN>

本文介绍了一个简单的Java程序,用于验证输入的社会安全号码(SSN)是否符合标准格式。程序通过检查输入字符串的长度及特定位置上的字符来判断SSN的有效性。
/*
Enter your SSN: 123-45-666666
Invalid SSN.
Enter your SSN: okl-33-4444
Invalid SSN.
Enter your SSN: 123-45-6789
Valid SSN
 */
import java.util.Scanner;

public class CheckSSN {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter your SSN: ");
        String SSN = input.nextLine();

        final int SIZE = 11;
        for (int i = 0; i < SIZE; i++) {
            if (SIZE != SSN.length() || !Character.isDigit(SSN.charAt(i))) {
                if (i == 3 || i == 6) {
                    if (SSN.charAt(i) == '-' || SSN.charAt(i) == '-')
                        continue;
                }
                System.out.println("Invalid SSN.");
                System.exit(0);
            }
        }
        System.out.println("Valid SSN");
    }
}
sc35% /mnt/may1nov1/u3101/SSN2/OrthoFinder/.orthofinder zsh: no such file or directory: /mnt/may1nov1/u3101/SSN2/OrthoFinder/.orthofinder sc35% ./OrthoFinder/orthofinder -h OrthoFinder version 2.5.5 Copyright (C) 2014 David Emms SIMPLE USAGE: Run full OrthoFinder analysis on FASTA format proteomes in <dir> orthofinder [options] -f <dir> Add new species in <dir1> to previous run in <dir2> and run new analysis orthofinder [options] -f <dir1> -b <dir2> OPTIONS: -t <int> Number of parallel sequence search threads [Default = 32] -a <int> Number of parallel analysis threads -d Input is DNA sequences -M <txt> Method for gene tree inference. Options &#39;dendroblast&#39; & &#39;msa&#39; [Default = dendroblast] -S <txt> Sequence search program [Default = diamond] Options: blast, diamond, diamond_ultra_sens, blast_gz, mmseqs, blast_nucl -A <txt> MSA program, requires &#39;-M msa&#39; [Default = mafft] Options: mafft, muscle -T <txt> Tree inference method, requires &#39;-M msa&#39; [Default = fasttree] Options: fasttree, raxml, raxml-ng, iqtree -s <file> User-specified rooted species tree -I <int> MCL inflation parameter [Default = 1.5] --fewer-files Only create one orthologs file per species -x <file> Info for outputting results in OrthoXML format -p <dir> Write the temporary pickle files to <dir> -1 Only perform one-way sequence search -X Don&#39;t add species names to sequence IDs -y Split paralogous clades below root of a HOG into separate HOGs -z Don&#39;t trim MSAs (columns>=90% gap, min. alignment length 500) -n <txt> Name to append to the results directory -o <txt> Non-default results directory -h Print this help text WORKFLOW STOPPING OPTIONS: -op Stop after preparing input files for BLAST -og Stop after inferring orthogroups -
03-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值