Question

In: Computer Science

You will write a single class named WordsXX- replace the XX's with your initials. The program...

You will write a single class named WordsXX- replace the XX's with your initials.

The program will have 2 overloaded methods named wordMaker. They will have to be declared as static. Both methods will not have a return type but they will print some text.

The first method wordMaker signature will not accept any parameters and when invoked will simply print out the line "lower case words".

The second overloaded wordMaker method will accept an integer and print "Words in UPPER CASE" . The method will print the phrase as many times as the parameter indicates with each new iteration printed on a new line.


Write a main method that prompts users to enter either the word "lower" or "upper". (Make sure you allow for all varieties of capitalization.)

If they enter "upper" then generate a random number from 3-9 and call wordMaker to print the upper case phrase that many times.

If they enter "lower" it will use the other version of the method.

can you guys do it right now please this is so urgent please do it Java

Solutions

Expert Solution

import java.util.Random;
import java.util.Scanner;
public class Main
{
    public static void wordMaker()
    {
        System.out.println("lower case words");
    }
    
    public static void wordMaker(int n)
    {
        for(int i = 0;i<n;i++)
            System.out.println("words in UPPER CASE");
    }  
    
    public static void main(String[] args) 
        {
            Scanner sc= new Scanner(System.in);
            System.out.print("Enter 'upper' or 'lower' : ");  
        String str= sc.nextLine();
        str = str.toLowerCase();
        Random random = new Random();
                if(str.equals("upper"))
                    wordMaker(random.nextInt(6)+3);
                else if(str.equals("lower"))
                    wordMaker();
                else
                    System.out.print("Invalid input");  
        }
}

Let me know if you need any changes, I'll try to get it done ASAP


Related Solutions

You will write a single class named WordsXX- replace the XX's with your initials. The program...
You will write a single class named WordsXX- replace the XX's with your initials. The program will have 2 overloaded methods named wordMaker. They will have to be declared as static. Both methods will not have a return type but they will print some text. The first method wordMaker signature will not accept any parameters and when invoked will simply print out the line "lower case words". The second overloaded wordMaker method will accept an integer and print "Words in...
Write a java program that has a class named Octagon that extends the class Circ and...
Write a java program that has a class named Octagon that extends the class Circ and implements Comparable (compare the object's area) and Cloneable interfaces. Assume that all the 8 sides of the octagon are of equal size. Your class Octagon, therefore, must represent an octagon inscribed into a circle of a given radius (inherited from Circle) and not introduce any new class variables. Provide constructors for clas Octagon with no parameters and with 1 parameter radius. Create a method...
Write a program (name it firstMiddleLast _yourInitials.java (yourInitials represents your initials) that will: 1. Ask the...
Write a program (name it firstMiddleLast _yourInitials.java (yourInitials represents your initials) that will: 1. Ask the user (include appropriate dialog) to enter their: first name middle name last name save each of the above as a String variable as follows: firstName middleName lastName 2. Print to the screen the number of characters in each of the names (first, middle and last) 3. Print to the screen total number of characters in all three names. Include appropriate dialog in your output....
Write a C++ program (The Account Class) Design a class named Account that contains (keep the...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator functions for id, balance, and annualInterestRate....
Write a tester program to test the mobile class defined below. Create the class named with...
Write a tester program to test the mobile class defined below. Create the class named with your id (for example: Id12345678) with the main method. Create two mobiles M1 and M2 using the first constructor. Print the characteristics of M1 and M2. Create one mobile M3 using the second constructor. Change the id and brand of the mobile M3. Print the id of M3. Your answer should include a screenshot of the output. Otherwise, you will be marked zero for...
Write a complete java program that Define a class named sample containing: A method named division...
Write a complete java program that Define a class named sample containing: A method named division that receives two integers x and y and returns the division of the two numbers. It must handle any possible exceptions. A method named printArray that receives an array of double arr and an integer index and prints the element in the positon index. It must handle any possible exceptions. main method that recievs input from user and repeat if wrong input. Then it...
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
PYTHON Suppose you need to import a single class named GeneTools from a module named bioinformatics,...
PYTHON Suppose you need to import a single class named GeneTools from a module named bioinformatics, in Python. Which of the following represents the correct use of an import statement? import GeneTools from bioinformatics from bioinformatics import GeneTools from bioinformatics import * import GeneTools
write JAVA program have a public class named GeometricShapes that has the main() method. In the...
write JAVA program have a public class named GeometricShapes that has the main() method. In the main() method the user needs to select if he want 2D shapes or 3D shape -if user select 2D user needs to select the shape type (Square, Circle, or Triangle) after selected shape the user needs to specify whether to find the Area or the Perimeter or to find side-length (radius for the circles), accordingly the needed constructor is used. (using Polymorphism principle) -if...
Assignment Write a program using turtle graphics which writes your initials, or any other three unique...
Assignment Write a program using turtle graphics which writes your initials, or any other three unique letters, to the display. Look to your program for lab 1 for reminders of how to use turtle graphics. Functions that must be written: def drawLetter (x, y, letterColor): Write three functions, one for three unique letters. Personally, I would write drawA, drawR, and drawS. Each function must draw that letter to the screen. The x and y values determine the upper left-hand location...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT