Goal of this code: the user types words such as "save" etc. The program gives save and save command. On "exit" the LOOP WHILE has to stop..... ;( I tries this code...but unfortunetaly it doesnt work ;( need some help please ;(
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package scvprocessor.another.version;
import java.util.Scanner;
/**
*
* @author c2rsaldi
*/
public class SCVProcessorAnotherVersion {
static Scanner message = new Scanner(System.in);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Type a command");
String inputMessage = message.nextLine();
inputText (inputMessage) ;
System.out.println(inputText (inputMessage));
// TODO code application logic here
}
public static String inputText (String inputMessage) {
while (!(inputMessage.equals(' '))) {
if (inputMessage.contains("print")) {
return inputMessage +"\n"+"Print Command";
} else if (inputMessage.contains("save")) {
return inputMessage + "\n"+"Save Command";
}
else if (inputMessage.contains("=")) {
return inputMessage+"\n"+"Assignment command";
} else if (inputMessage.contains("exit")) {
return inputMessage+"\n"+"Exit command";
break;
} else
{return (inputMessage + "\n" + "Unknown command");
}
}
}
}
This post has been edited by no2pencil: 10 October 2012 - 11:58 AM
Reason for edit:: Added Code Tags

New Topic/Question
Reply



MultiQuote







|