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
An employee sets up an automation that transfers files in a specific folder on their PC to a remote drive for archiving, provide
Yuri [45]

Answer:

Rule based automation

Explanation:

8 0
2 years ago
Robots are increasingly being used in caring roles. Discuss the ethical and cultural implications of this trend
vekshin1
Using more robots means less human contact which means declining social skills, and heavier dependence on technology. And using more technology is expensive.
4 0
3 years ago
A ____ is an electronic device, operating under the control of instructions stored in its own memory, that can accept data, proc
taurus [48]

Answer:

Server

Explanation:

- it is an electronic device

- under control of another computer or human

- stored instructions as code

- accepts data from external source

- process the data it gets, for example filtering the data or modifying it

- produces information, for example AI created suggestions

- Stores Information on storage drives

6 0
3 years ago
Read 2 more answers
What are some of the current trends in fashion?
jonny [76]

Answer:

1. pocket sized

2. muted

3. children

Full Paragraph :

For women, pocket sized tote bags and high-heeled sandals are popular now. For men, muted colors are the new trend. Bomber jackets and prints are also a fad among children.

Yeah that's basically the new trends in fashion. =v=  

5 0
3 years ago
Can someone help me pz?
Katarina [22]
Yes definitely. now what do you need help with?
8 0
3 years ago
Other questions:
  • Which of the following is an example of a logic bug?
    8·1 answer
  • Are commonly used to control the number of times that a loop iterates?
    5·1 answer
  • Approximately what percentage of the world population owns a smartphone?
    9·1 answer
  • Not providing guarding or fall protection for workers on a 25-foot scaffold. The resulting fall would most likely end in death,
    6·1 answer
  • Write down the steps that you will take to organize your files
    12·2 answers
  • What is something that can be done to help stop teen teen crashes
    8·1 answer
  • Introduction to Identity and Fitting In
    7·1 answer
  • Which of the following statement is correct? Select one: a. Base register holds the size of a process. b. Limit register holds t
    10·1 answer
  • What do you do when ur grounded from all electronics and can't go outside and have t clean all day
    10·1 answer
  • What is the remainder obtained by dividing x 7 + x 5 + 1 by the generator polynomial x 3 + 1?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!