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
testout You want to prevent users in your domain from running a common game on their machines. This application does not have a
Margarita [4]

Answer:

Hash condition is the correct answer to the following question.

Explanation:

Hash condition provided more security than the applocker file path rule and it is manually for the files.

  • It is more secure than the path rule because each file has its separated hash condition.
  • Drawback of hash file is every time whenever when file is updated then we have to update the file hash condition.
8 0
3 years ago
Luis got himself in trouble by accidentally sending an e-mail to a client instead of his coworker. He resolved to be more carefu
Elodia [21]

Answer:

Explanation:

There are two main practices that Luis needs to make into a habit of doing every time he sends an e-mail, these are

  • Being careful when using the Reply to All feature.
  • Double-checking the Cc and Bcc fields.

Taking into account both of these practices will make sure that Luis is sending the written e-mail to the correct individual's address and also making sure that he is not sending the e-mail to any other individual by accident when using the Reply to All feature.

7 0
3 years ago
A researcher saved her draft work on a CD ROM from a friends computer with an intention of sending it to her supervisor by e-mai
kicyunya [14]

Answer:

mail the cd to the supervisor

Explanation:

6 0
2 years ago
Explain briefly how the cooling mechanism implemented in fan less laptop
liraira [26]
<span>Fanless computers use a heat sink and taking the heat produced from the computer and dissipating heat. The heat sink is made of a highly heat conductive material such as aluminum. It is connected to the CPU with thermal paste to maximize the amount of heat transferred to it and then connects to the outside air most commonly in an area with many ridges to maximize air contact.</span>
4 0
4 years ago
What is the range of addresses for conditional branches in MIPS (K = 1024)?
sergejj [24]
Addresses up to about 128K before the branch to about 128K after.
3 0
3 years ago
Other questions:
  • Alex needs to create a function capable of counting item reference numbers that he is inserting into a spread sheet. The purpose
    15·1 answer
  • What is the name of the organization responsible for assigning public ip? addresses?
    5·1 answer
  • What does ACCU stand for?
    13·2 answers
  • Which one of the following is NOT true about energy conversion devices? Group of answer choices Total Energy Input = Energy Diss
    8·1 answer
  • Whats the best app for cheaters​
    9·1 answer
  • How will using ascending order on a field that contains dates sort a list?
    12·2 answers
  • To place controls on a form in a stacked layout, select all the controls and click the stacked button on the ____ tab.
    7·1 answer
  • The Harrison Group Life Insurance company computes annual policy premiums based on the age the customer turns in the current cal
    5·1 answer
  • Hat are the technical risks and the human risks for the ticktacktoe game
    15·1 answer
  • Does anyone know how I can make this return a double with 2 decimal places?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!