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
Is greedy algorithm non deterministic by nature?
Flura [38]

Answer: Yes

Explanation: Greedy algorithm is the algorithm that gives the solution to the problem on the basis of the piece by piece or step by step architecture.  the next step of the solution is based on the aim of solving problem optimally.But the steps chosen can be correct or incorrect.

Non-deterministic nature is the feature that determines that the  steps that is being chosen is not the most optimal one and no high surety is present.Thus, this nature is present in the greedy algorithm and it has non-deterministic nature.

7 0
3 years ago
Which would take more storage space, a layer file showing all the us counties or a layer file showing all the us states?
Ksju [112]
All counties. Much more info. Although most layers are just excel files with geographical reference data in them. That one file may be several MB as the state file may be 1mb or less
5 0
3 years ago
Which of the following is true about STEM education? STEM education is focused on understanding rather than applying scientific
Soloha48 [4]

Answer:

C). STEM students are encouraged to blend and expand their knowledge of all four subject areas.

Explanation:

STEM education is characterized as a learning and development approach that focuses upon an amalgamation of four subject areas including science(S), technology(T), engineering(E), and Mathematics(M). Thus, each letter stands for a subject domain and this integration of four subjects primarily aims to 'blend and expand the knowledge of the students in these areas' integratively. It helps in developing and sustaining the interests of young learners through this integrated approach which also assists them with unique opportunities. Thus, <u>option C</u> is the correct answer.

5 0
3 years ago
Which port security violation mode does not generate messages or increment the violations counter?
Zanzabum

The number of violations is increased. When a secure port is in the error-disabled condition, the shutdown and restrict command can be used to restore it.

<h3>What is  offence?</h3>

A deviation from a code of conduct or law is referred to as a violation. When driving a car, going over the posted speed limit is a regular legal violation. Invading someone else's privacy could include reading their journal. failure to uphold a duty or right; breaching the law.

The two types of violations are states and acts. A transgression is a violation of the rules that is less serious than a foul and frequently involves technicalities of the game. A disrespectful or vulgar act: profanation.

Hence, The number of violations is increased. When a secure port is in the error-disabled condition, the shutdown and restrict command can be used to restore it.

To learn more about violation, refer to:

brainly.com/question/1274113

#SPJ4

4 0
2 years ago
Benefits of etherchannel
Mariana [72]
An ether channel can give you high speed interface if it is successfully engineered. Combining 2 or more ethernet lets you create a logical ethernet link providing high speed links between switches. Also having etherchannel gives you a higher band width than what you costumed for.
5 0
3 years ago
Other questions:
  • Which of these can be considered data?<br> A:facts<br> B:information<br> C:belief<br> D:all of these
    9·1 answer
  • A(n) _____ is a type of man-in-the-middle attack where an attacker captures the data that is being transmitted, records it, and
    15·2 answers
  • The Change Speed command in Audacity lets you change which two things about a track at the same time?
    9·1 answer
  • Who plays Roblox and wants to be friends on it
    9·2 answers
  • Computer privacy typically occurs when which of the following is violated?
    6·1 answer
  • The term packet is used fairly generically to refer to protocol data unit (PDU). There are PDU equivalent names in the different
    15·1 answer
  • An important goal of biosecurity training is to: Prevent laboratory accidents that could expose personnel to hazardous agents. P
    13·1 answer
  • Quick!! Im taking a timed test so pls hurry!! Ill even mark as brainliets!!
    5·2 answers
  • 20 POINTS!!! I NEED HELPP
    6·2 answers
  • Question 1
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!