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
7.3 Code Practice edhesive
sladkih [1.3K]

Answer:

def print_sum(a,b,c):

 print(a+b+c)

one = int(input("Enter the 1st number: "))

two = int(input("Enter the 2nd number: "))

three = int(input("Enter the 3rd number: "))

print_sum(one,two,three)

Explanation:

hope this helped :)

5 0
2 years ago
Read 2 more answers
A shop will give discount of 10% if the cost of purchased quantity is more than 1000. Ask user for quantity suppose, one unit wi
UkoKoshka [18]

Answer:

The program in Python is as follows:

qty = int(input("Quantity: "))

price = 100 * qty

if qty >1000:

    price = (100 - 0.10 * 100) * qty

print("Cost: "+str(price))

Explanation:

This prompts the user for the quantity

qty = int(input("Quantity: "))

This calculates the price or cost, without discount

price = 100 * qty

This checks if the quantity is greater than 1000

if qty >1000:

If yes, this calculates the price or cost, after discount

    price = (100 - 0.10 * 100) * qty

This prints the calculated cost

print("Cost: "+str(price))

4 0
2 years ago
What is nested selection?
kodGreya [7K]

Answer:

I think its 4 I'm not so sure though

7 0
2 years ago
Which device makes telecommunications possible?
Dmitrij [34]
A. modem or d. voice input. Not a port because a port allows one to insert a peripheral device but not really communicate. I have no idea what an expansion slot is. It could be d. voice input because this allows a person to hold an audible conversation.

But  I'd go for modem because a modem lets you connect devices like laptops, tablets, phones, computers etc. and share data between them. So things like mailing are possible (I THINK)!  <span />
7 0
2 years ago
Early word processors ran on devices that look like digital
S_A_V [24]

Answer:

True

Explanation:

The word processor used to be the only office machine in the year 1960s, that combined the keyboard text-entry and various printing functions of an electric typewriter with the recording memory. And this recording unit was a tape or a floppy disk, with the simplest of processor applied for text editing. Hence, the above statement that the early word processors ran on the devices that look like digital is true.

6 0
2 years ago
Read 2 more answers
Other questions:
  • Explain the difference between an i/o‐bound process and a cpu‐bound process.
    12·1 answer
  • You can leave out the ____ statements in a switch structure.
    15·1 answer
  • What system of representation is used for the threaded portions
    12·1 answer
  • While you are working on your computer, it shuts down unexpectedly, and you detect a burning smell. When you remove the case cov
    9·1 answer
  • What resources can be shared over a computer network?
    12·2 answers
  • We want to transmit 40 packets and the following packets are getting lost, 3,9, 25,28, 35. How many rounds are needed if
    5·1 answer
  • Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
    9·1 answer
  • Why is it difficult to convince top management to commit funds to develop and implement SIS
    5·2 answers
  • What is the second row of letters in the keyboard called?
    6·1 answer
  • Sorry, I cant tell you, you need to know
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!