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]
3 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]3 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
To help determine which technology to use, Raul creates a table to help him compare the pros and cons of his choices. What part
love history [14]

The answer is analyzing choices/options

Analyzing choices/options is one of the several steps of the decision making processes. Analyzing your choices will help you determine how your final decisions will impact yourself and everyone else around you. It is in this step that you will be asking yourself the likelihood of the results of your decisions now and in the future. In addition, this step will help you review the pros and cons of your choices listed in the previous steps.

5 0
3 years ago
You have a small company and want to keep your costs low, but it is important your employees share data. Which network would pro
Crank

Answer:

centralised

Explanation:

duhh

7 0
2 years ago
Read 2 more answers
A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
BaLLatris [955]

Answer:

The answer is that it is a speaker note.

Explanation:

It leaves a note for people that use presentation files. I use it all the time on my google slides.

7 0
2 years ago
Pre-made, copyright-free illustrations are called __________. apps clip art graphic design stock photos
IceJOKER [234]

Answer: clip art

Explanation:

  • The clip arts are graphic images that are pre-made illustrations for the purpose of creating any medium (designs or art).
  • It has no restrictions to use them, it can be used by anyone, hence its copyright-free.
  • It comes in both electronic and printed form.
  • But mostly they are designed and distributed and used by a person in an electronic form.

Hence, the complete statement is "Pre-made, copyright-free illustrations are called <u>clip art</u>".

7 0
2 years ago
Has anyone used freya on Mobile legends bang bang
Vsevolod [243]
Yeaaaaahhh it’s so fun
4 0
3 years ago
Read 2 more answers
Other questions:
  • python If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts t
    10·1 answer
  • How to turn a flash drive into a bluetooth adapter?
    13·1 answer
  • Hello, can you help me answer these questions?
    9·2 answers
  • What part of a check is the LEAST important?
    14·2 answers
  • Differentiate between the broadcasting and telecommunication
    5·1 answer
  • The frequencies licensed by telecommunication firms to provide wireless service is known as _____.
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    5·1 answer
  • A total stranger is trolling Jack online. He’s offended and annoyed. How can Jack stop the troll in his or her tracks? (5 points
    10·2 answers
  • Davingould1115...................answer 3​
    11·1 answer
  • Write a program that uses a structure to store the following data about a customer account: Name Address City, State, and ZIP Te
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!