Write a JAVA program that has 2 methods with the same name: printCaps(String input) prints the input in capital letters, printCaps(String input, int num) prints in capital letters the specified number of times on a new line:
public static void printCaps(String input)
public static void printCaps(String input, int num)
import java.util.Scanner;
public class PrintCaps {
public static void printCaps(String input) {
System.out.println(input.toUpperCase()); // print input in uppercase
}
public static void printCaps(String input, int num) {
for (int i = 0; i < num; i++) { // iterate num times
printCaps(input); // print input in uppercase using the above method
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a string: ");
String s = in.nextLine(); // read a string from user
System.out.print("How many times do you want to print it? ");
int n = in.nextInt(); // read a number from user
printCaps(s, n); // call printCaps
}
}

Write a JAVA program that has 2 methods with the same name: printCaps(String input) prints the...
Write a JAVA program that has a method which accepts a string and prints it back to the user with all vowels replaced with *'s (multiple asterisks not '*s') with a new line after the string. The method signature should look like this: public static void replacePrint(String input)
1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...
Write a program that stores a phrase as an array of words, and then prints it backwards. The main method calls method getInput , which asks the user how many words there are, stores them in an array, and returns this array. printBackwards then takes this array of words, and prints it in reverse. Code Example: import java.util.Scanner; public class L17Num1{ public static void main(String[] args) { String[] sArray=getInput(); printBackwards(sArray); } public static String[] getInput() { System.out.println("How many...
Write a program in Java that prompts a user for Name and id number. and then the program outputs students GPA MAIN import java.util.StringTokenizer; import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { String thedata = JOptionPane.showInputDialog(null, "Please type in Student Name. ", "Student OOP Program", JOptionPane.INFORMATION_MESSAGE); String name = thedata; Student pupil = new Student(name); //add code here ...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
You will write three static methods to manipulate an input
String in different ways using various String methods. You need to
provide the code for each of the three static methods in class
StringPlay (requirements for each listed below). You will also
change the control statement in the test harness to allow for
variations in the sentinel value. You need to modify the loop
control condition in Lab09.java so that user inputs of ‘finish’,
“FINISH”, “FiniSH”, “fINISH”, etc. will end...
Write a Java program which takes a string as a user input. Create 2 functions. The first function expects a string as argument and returns void. It converts all upper case characters to lower case and converts all lower case characters to upper case. It then prints out the converted string to a console. The second function also expects a string as argument and returns void. It will find first charactor that is repeated exactly 2 times in the string....
Write a program that will check a Java file for syntax errors. The program will ask for an input-file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: 1. Any syntax error found in the Java input file will be corrected: a. Missing semicolon b. Missing compound statements (curly braces) c. All comments have to start with // and end with a period....
JAVA: Write a program that prints a rectangle with a border of asterisks (*). Prompt the user for the width and height of the rectangle. For example: Enter the width and the height of our box. 3 5 *** * * * * * * *** import java.util.Scanner; public class DrawBox { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the width and the height of our box."); /* Type your code here. */...
I need a java program that prints the following: 1* 2** 3*** 4**** 5***** 6****** 7******* 8******** 9********* This is what I have so far, but I cannot figure out how to fix it. public class HelloWorld{ public static void main(String []args){ System.out.println("Pattern Two"); for (int line=1; line<10; line++){ System.out.println(); for (int j=1; j System.out.print(line); for (int i=1; i System.out.print("*"); } } } } }