|
-
Nov 23rd, 2009, 05:37 AM
#1
Thread Starter
New Member
Program that reads letters
Well, i need to write program (school project) that reads letters and checks if you can form a sentence from the sentence / letters user has given to the program. (confusing?) Also after it has read it, it should check what letters are needed if it cant form it and what letters are spare if it can form it. sorry if its confusing, the sentence should be "learning is fun"
Heres the output what it should be like.. well at least something like this
welcome
give the sentence: learning is funny
sentence can be formed, the spare letters are n,y
ANY HELP WILL HELP, I have to get this done asap but i just don't have the skill for it yet. ( been tryin )
Edit: I know the basic int etc but cant make it work really, also i know scanner.. some of it.
Heres what i got so far..
Code:
i// MuokkaaTeksteja.java
//
import java.io.*;
class testia {
public static void main
( String [] args ) throws IOException {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String mjono;
int valinta;
System.out.println("Tervetuloa!");
System.out.println("Syötä lauseesi");
mjono = stdin.readLine();
do{
valikkoMetodi();
valinta = Integer.parseInt(stdin.readLine());
switch (valinta) {
case 1:
suurennaMetodi(mjono);
System.out.println(suurennaMetodi(mjono));
System.out.println();
break;
case 0:
break;
default: System.out.println("Väärä valinta");
}
} while (valinta != 0);
}
public static void valikkoMetodi() {
System.out.println("Valitse haluamasi toiminto: ");
System.out.println();
System.out.println("1) Tarkista voiko lauseestasi muodostaa Opiskelu on hauskaa");
System.out.println();
System.out.println("0) Lopeta ohjelma");
System.out.println();
}
public static String suurennaMetodi(String mjono) {
String mjonosuuri = null;
mjonosuuri = mjono.toUpperCase();
return mjonosuuri;
} // suurennaMetodi
public static String vaihdaJarjestysMetodi(String mjono) throws IOException {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String mjonokaannetty = null;
int pituus;
int i;
pituus = mjono.length();
for (mjono = stdin.readLine(), i = 0; i < pituus; i++) {
mjonokaannetty += Character.toString(mjono.charAt(pituus - i));
}
return mjonokaannetty;
}
}
Last edited by emtmitalaitan; Nov 24th, 2009 at 02:31 AM.
-
Nov 24th, 2009, 02:04 AM
#2
Thread Starter
New Member
Re: Program that reads letters
C'mon, anyone? What the code in my previous post does is == it makes ur sentence to uppercase. and quits..
Last edited by emtmitalaitan; Nov 24th, 2009 at 02:32 AM.
-
Nov 24th, 2009, 05:10 AM
#3
Re: Program that reads letters
What is your question exactly?
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Nov 30th, 2009, 11:07 PM
#4
Re: Program that reads letters
if all sentences are derived from "learning is fun" then you can use regular expressions to check if user supplied sentence is similar, as well as for identifying excess characters.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|