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)

public static void replacePrint(String input) {
for (int i = 0; i < input.length(); i++) { // go through all characters
char ch = input.charAt(i);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {
System.out.print("*");
} else {
System.out.print(ch);
}
}
System.out.println();
}

public class VowelsReplace {
public static void replacePrint(String input) {
for (int i = 0; i < input.length(); i++) { // go through all characters
char ch = input.charAt(i);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {
System.out.print("*");
} else {
System.out.print(ch);
}
}
System.out.println();
}
public static void main(String[] args) {
replacePrint("Hello How are you?");
}
}

Write a JAVA program that has a method which accepts a string and prints it back...
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)
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. */...
Complete the printPalindrome method in the provided Palindrome.java program. The printPalindrome method accepts a String as a parameter and prints whether the parameter String is a palindrome (i.e., reads the same forwards as it does backwards, for example, "abba" or "racecar"). Make the code case-insensitive, so that words like "Abba" and "Madam" will be considered palindromes. import java.util.*; /** * Determines if a user entered String is a palindrome, which means the String * is the same forward and reverse....
Write a program that takes a String containing a text using the method signature String useProperGrammar(String text) Your method should replace the word ‘2’ with ‘to’ and return the updated text. For example, useProperGrammar("can you go 2 the store?") should return "can you go to the store?" This method should also print out the number of grammatical errors that were fixed. For example, for useProperGrammar("back 2 back 2 back"), the method would also print: Fixed 2 grammatical errors: In the...
JAVA Write a method that accepts a String as an argument. The method should use recursion to display each individual character in the String. Then, modify the method you just wrote so it displays the String backwards. The following code does not correctly display the String backwards. It merely moves the first character of the String to the end: public static void displayCharacter(String s) { if(s.length() == 0) return; else ...
and then print their average. Write a C program that accepts a string of text from the user and prints back the string without any of the vowels. For example, if the user entered "Hello, world", the program should print "Hll, wrld" Write a C program that accepts an integer in decimal from the user and prints the number of 1' bits in the integers binary representation. For example, if the user entered 14, the program should print 3 because...
WRITTEN IN JAVA Complete the method printIndices that accepts a String source and a character search, and prints the position of each occurrence of the search value in source. For example: Input: source = "String Programming in Java is fun", search = 'i' Console Output: 3 15 19 27 Template provided from question: public static int printIndices(String source, char search) { } public static void main(String[] args) { System.out.println("Expected printIndices() prints indices 3...
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...
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 static method called printWithSpaces that takes a String as its parameter and prints the characters of the string separated by spaces. For example: > Methods.printWithSpaces("method") m e t h o d You should have a single space after the last character. This method should not return a value. That is similar to this code for printing the string vertically public static void printVertical(String s) { for (int i = 0; i < s.length(); i++) { char c =...