Results 1 to 4 of 4

Thread: Program that reads letters

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    2

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width