guys i really need your help about my project anyone can help me i will appreciate it because its due on 3/3/11.
thank you and GOD bless!

1.Write a program that takes a one-line sentence as input and outputs the following response: If the sentence ends with a question mark ‘?’ and the input contains an even number of characters, then output the word “Yes”. If the sentence ends with a question mark ‘?’ and the input contains an odd number of characters, then output the word “No”. If the sentence ends with an exclamation mark ‘!’, output the word “Wow”. In all other cases, your program will output the string You always say followed by the input string enclosed in quotes. Your output should all be on one line.

2.Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Test your program with at least 4 strings of different lengths and ending punctuation.

In the mean time you can you look at the java.lang.String API. There are methods you can use. I think there is one called "endsWith".

In the mean time you can you look at the java.lang.String API. There are methods you can use. I think there is one called "endsWith".

thanks for the info

guys i really need your help about my project anyone can help me i will appreciate it because its due on 3/3/11.
thank you and GOD bless!

1.Write a program that takes a one-line sentence as input and outputs the following response: If the sentence ends with a question mark ‘?’ and the input contains an even number of characters, then output the word “Yes”. If the sentence ends with a question mark ‘?’ and the input contains an odd number of characters, then output the word “No”. If the sentence ends with an exclamation mark ‘!’, output the word “Wow”. In all other cases, your program will output the string You always say followed by the input string enclosed in quotes. Your output should all be on one line.

2.Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Test your program with at least 4 strings of different lengths and ending punctuation.

i want to say sorry about this yeah your right i need to start first before i ask for help so thank you

Can anyone explain me to do this please i'm not asking for the code i just want to understand this problem,,, thanks

Can anyone explain me to do this please i'm not asking for the code i just want to understand this problem,,, thanks

Why don't you tell as in maybe some bullet points what you think you are asked to do? To understand project needs/requirement is one of the many things on long list of abilities of a programmer.

i was doing the program it compiles but i cant get the output

import java.util.*;

public class Sentence
{
	 static Scanner keyboard = new Scanner(System.in);
	 
	 public static void main(String[] args)
	 {
	    
	    int she;
	 	System.out.print("Enter you words:");	 	 	
	 	she = keyboard.nextInt();
	 	System.out.println();
	    
	 	
	 	
	 	switch (she)
	 	{
	 		case 2: case 4:case 6: System.out.println ("Even number of characters," 
	 		                            + "last character is '?'");
	 	    System.out.println("Input: " + she);
	 		    break;
	 		case 1: System.out.println("Odd number or characters,"
	 		                           + "last character is '?'");
	 	    System.out.println("Input: " + she); 
	 	    	break;
	 		case 5: System.out.println("Last character is '!'");
	 	    System.out.println("Input: " + she);	
	 	     	break;
	 		case 0: System.out.println("All other cases");
	 		 	break;
	 		default: System.out.println("You alyaws say "+ she);
	 	
	 	} 	
	 }

}

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

First thing first. Ask user for input, read input and store it in the string. After that you will use it to pass as parameter for different operations you will call on it.
So replace line 12 with string equivalent of your integer currently used.

import java.util.*;

public class Sentence
{
	 static Scanner keyboard = new Scanner(System.in);
	 
	 public static void main(String[] args)
	 {
	    
	  String she;
	 	System.out.print("Enter you words:");	 	 	
	 	she = keyboard.nextLine();
	 	System.out.println(she);

		/** Make calls to bellow stated methods and act on the results. Do not forget to use trim method to remove any tailing empty spaces
		*/
	 }

	 public static boolean endsWithQuestionMark(String sentemce){
			//return true or false if ends with "?"
	 }

	 public static boolean endsWithExplanationMark(String sentence){
			//return true or false if ends with "!"
	 }
}

Edited 5 Years Ago by peter_budo: n/a

This article has been dead for over six months. Start a new discussion instead.