I have to write a java program for my class in uni, where the program is supposed to prompt the user to enter a 6 - letter word, then once that is done it has to print one or two sentences depending on whether the word has certain properties, for example:
Affhin - the output would be : The letters Affhin are in ascending order.
zxvrda - the output would be : The letters zxvrda are in descending order. The letters zxvrda are all lowercase.
xxXxx - the output would be : the letters in xxXxx are all the same.
QWERTY - the output would be : The letters QWERTY are all uppercase.
but if the user entered QwertY - the output would be : There is nothing special about this word.
so far i've written this
import java.util.Scanner;
public class program
{
public static void main (String[] args)
{
String Word;
Char L1, L2, L3, L4, L5, L6
Scanner keyboard = new Scanner (System.in);
System.out.print ("Hello please enter a 6-letter word: ")
Word = keyboard.nextLine();
if (Word.length() > 6)
{
System.out.print ("Your word is too long "+ , +" please try again!")
System.exit (0);
}
// end if
if (Word.length() < 6)
{
System.out.print ("Your word is too short "+ , +" please try again!")
System.exit (0);
}
// end if
soo, having said all that, my question is if im on the right path, and if so how the hell do i write the rest of this program so that it works correctly.?
any help is appreciated
also, please keep in mind that this is a begenning java course, so any code thats too advanced will more than likely get me called out by the professor and result in a F. I'm mostly looking for something that a begennier would use and something thats simple
Affhin - the output would be : The letters Affhin are in ascending order.
zxvrda - the output would be : The letters zxvrda are in descending order. The letters zxvrda are all lowercase.
xxXxx - the output would be : the letters in xxXxx are all the same.
QWERTY - the output would be : The letters QWERTY are all uppercase.
but if the user entered QwertY - the output would be : There is nothing special about this word.
so far i've written this
import java.util.Scanner;
public class program
{
public static void main (String[] args)
{
String Word;
Char L1, L2, L3, L4, L5, L6
Scanner keyboard = new Scanner (System.in);
System.out.print ("Hello please enter a 6-letter word: ")
Word = keyboard.nextLine();
if (Word.length() > 6)
{
System.out.print ("Your word is too long "+ , +" please try again!")
System.exit (0);
}
// end if
if (Word.length() < 6)
{
System.out.print ("Your word is too short "+ , +" please try again!")
System.exit (0);
}
// end if
soo, having said all that, my question is if im on the right path, and if so how the hell do i write the rest of this program so that it works correctly.?
any help is appreciated
also, please keep in mind that this is a begenning java course, so any code thats too advanced will more than likely get me called out by the professor and result in a F. I'm mostly looking for something that a begennier would use and something thats simple
Comment