1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ivahew [28]
4 years ago
10

Problem 1: you must write a method for this problem called sentenceAnalyzer Write a program that reads a sentence from the keybo

ard. Depending on the last character of the sentence, generate output identifying the sentence as declarative (ends with a period), interrogative (ends with a question mark), exclamatory (ends with an exclamation point), or unknown.
Computers and Technology
1 answer:
forsale [732]4 years ago
8 0

Answer:

   static void sentenceAnalyzer(String sentence){

       int lenOfString = sentence.length()-1;

   

           if(sentence.charAt(lenOfString)=='.'){

               System.out.println("Declarative");

             

           }

           else   if(sentence.charAt(lenOfString)=='?'){

               System.out.println("Interrogative");

             

           }

           else if(sentence.charAt(lenOfString)=='!'){

               System.out.println("Exclamation");

             

           }

           else{

               System.out.println("Unknown");

             

           }

   

   }

Explanation:

Using Java programming language

Create the method as required

Obtain the index of the last element using the string length method

Use if and else statements to check if the character at the last index is equal to any of the characters given and print the expected output

see a complete code with the main method below

<em>import java.util.Scanner;</em>

<em>public class num11 {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner in = new Scanner(System.in);</em>

<em>        //Receiving User input</em>

<em>        System.out.println("Enter a sentence");</em>

<em>        String sentence = in.nextLine();</em>

<em>        // Calling the method</em>

<em>        sentenceAnalyzer(sentence);</em>

<em>    }</em>

<em>    static void sentenceAnalyzer(String sentence){</em>

<em>        int lenOfString = sentence.length()-1;</em>

<em />

<em>            if(sentence.charAt(lenOfString)=='.'){</em>

<em>                System.out.println("Declarative");</em>

<em>            }</em>

<em>            else   if(sentence.charAt(lenOfString)=='?'){</em>

<em>                System.out.println("Interrogative");</em>

<em>            }</em>

<em>            else if(sentence.charAt(lenOfString)=='!'){</em>

<em>                System.out.println("Exclamation");</em>

<em>            }</em>

<em>            else{</em>

<em>                System.out.println("Unknown");</em>

<em>            }</em>

<em>    }</em>

<em>}</em>

<em />

You might be interested in
What is live ware in relation to computer​
Zarrin [17]

Answer:

It is a slang term used to denote people using (attached to) computers.

6 0
3 years ago
True or false: if we’re short side the subject in our composed frame, we have given the subject the maximum amount of “lead room
denis-greek [22]
I think it’s false I’m not to sure
3 0
3 years ago
Now, it’s time for you to begin coding your text-based adventure game!Starting at the top, convert each line of your pseudocode
alexira [117]

Answer:

what is your question? I can't answer this question haha

4 0
3 years ago
Read 2 more answers
Which network service would you use to get the ip address from the fqdn hostname?
Ann [662]
DNS (domain name system)
5 0
4 years ago
Browsers interpret html formatting instructions in order to display a document as a:
dolphi86 [110]
In order to display web pages, the browser interprets HTML formatting instructions. Web pages is a hypertext document and it is connected to the World Wide Web or called WWW. The web page or webpage is a document displayable by a browser and it is usually written in HTML or comparable markup language.
6 0
4 years ago
Other questions:
  • Trish uas bought a new computer, which she plans to start working on aftwr a week. Since Trish has not used computers in the pas
    13·1 answer
  • Which payment type is best if you are trying to sick to a budget?
    15·1 answer
  • Over a TCP connection, suppose host A sends two segments to host B, host B sends an acknowledgement for each segment, the first
    6·1 answer
  • Which of the following is a central feature of agroup?interactionmutual influenceinterdependenceall of the given options
    10·1 answer
  • What method of the Math object can be used to return the largest value from the values that are passed to it?
    14·1 answer
  • Which of the following is the definition of registration authority ( RA)?
    10·1 answer
  • Identify the problems that computer program bugs can cause. Check all that apply.
    9·2 answers
  • Which of the following is NOT an example of soft skill?
    10·2 answers
  • Draw a chart showing the crossing between red and white flowered pea plants till F2 generation. Find out the genotypic and pheno
    6·1 answer
  • You are asked to analyze events in a firewall log that occurred six months ago. when you analyze the log file, you notice events
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!