In: Computer Science
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
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