English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a program that reads two words representing passwords for the Java console and outputs the number of characters in the smaller of the two. For example, if the two words are open and sesame, then the output should be 4, the length of the shorter word, open.

I just started learning this in class, I don't think we went over this. It makes no sense to me. How do I answer this? What would the answer look like?

2007-02-04 16:44:15 · 2 answers · asked by Chestnut C 1 in Computers & Internet Programming & Design

2 answers

import java.io.*;
import java.util.*;

public class Test3
{
static java.io.PrintStream o = java.lang.System.out;

public static void main(String[] args) throws Exception{

String w1,w2;
int ww1,ww2;
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Text: ");
w1 = BR.readLine();
System.out.print("Enter Text again: ");
w2 = BR.readLine();
ww1=w1.length();
ww2=w2.length();
if(ww1 System.out.println(""+ww1+"");
}
else {
System.out.println(""+ww2+"");
}
}

}
I think that the answer would look like this =)

2007-02-04 20:55:51 · answer #1 · answered by Geinius 3 · 0 0

U can get help from here:
http://www.tutorialized.com/tutorials/Java/1

2007-02-05 00:55:02 · answer #2 · answered by cool _ sim 2 · 0 0

fedest.com, questions and answers