Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Two horses. Five monkeys. Twenty flies. One cat. Nine lives. Despite the English language being one of the most commonly used languages around the world,

Two horses. Five monkeys. Twenty flies. One cat. Nine lives. Despite the English language being one of the most commonly used languages around the world, it is also quite complicated to learn if you are not a native speaker. Taking a noun and converting it to its plural form has a dozen rules and even more special cases.

In this project, you will be creating a program that takes a given non-negative integer and a given singular noun as a String. You will have to print out the number, followed by the string in its plural form (unless the number is 1).

The given inputs are:

int amt;

String word;

For example, let's say your inputs are as follows:

# in: 4

word: apple

Your program should print out "4 apples"

# in: 0

word: apple

Your program should print out "0 apples"

# in: 1

word: apple

Your program should print out "1 apple"

Be prepared to handle the following rules:

Note that in order to handle cases where the word ends in y correctly, you will need to take some care. It is important that you order your conditions so that your code will check for the special case endings of ay, oy, ey, and uy before simply checking whether a word ends in y.

import java.util.Scanner;

class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("# in:"); int amt = inp.nextInt(); inp.nextLine(); //this line is necessary System.out.print("word:"); String word = inp.nextLine(); //leave the above unedited, write your code below: } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Define the term intellectual property and describe its importance.

Answered: 1 week ago

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago