Java, please. Work based on the code above.
Code:
import java.util.Scanner;
public class Question1
{
static String oddOneOut(String s)
{
String evens = ""; //to store every
even index character.
for(int i=0; i<s.length(); i++)
//reading each character in string.
{
if(i%2==0) //if
index is even
evens = evens+s.charAt(i); //adding to
evens
}
return evens; //returning string
containing evey even index characters.
}
public static void main(String[] args)
{
//creating a scanner, reading
input
Scanner in = new
Scanner(System.in);
String s = in.nextLine();
//calling the oddOneOut()
method
System.out.println(oddOneOut(s));
}
}
Outputs:
Note: my friend if you have any questions or queries comment below. I am happy to answer your all questions. I will sort out your queries. Thank you my friend.
Java, please. Work based on the code above. DESCRIPTION: The purpose of this question is offload...
DESCRIPTION: The purpose of this question is offload processing from the main method to a static helper method. You will be given the main method. Do not alter this code. Your goal is to write a new method called oddOneOut, which will accept a String, and print it in out every other letter. For example, if the String was "abcdefghijk", the oddOneOut method will return "acegik" . METHOD INPUT: A string METHOD PROCESSING: Do not alter the main method. Complete the...
DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...
DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...
in Java and with a code please! num Presses = 2, print: Press the q key 2 times to quit. 1 import java.util.Scanner; 3 public class Quit Screen public static void main(String[] args) { Scanner senr - new Scanner(System.in); char letter ToQuit; int numPresses; letterToQuit - scnr.next().charAt(); numPresses - scnr.nextInt(); /* Your solution goes here */ 12 13 14 15 ) )
Below is the code from LE 6.2 that LE 7.1 is referring to. import java.util.Scanner; public class lastNameLE62 { private static Scanner in = new Scanner(System.in); private static int size; public static void arraySize() { System.out.printf("How many sports are you interested in? "); size = Integer.parseInt(in.nextLine()); } public static String[] setFavoriteSports() { String []favSports = new String[size]; for(int i=1; i<=size; i++) { System.out.printf("Enter sport #%d: ", i); favSports[i-1] = in.nextLine(); } return favSports; } public static String[] setFavoriteTeams(String[] sports) {...
Given java code is below, please use it! import java.util.Scanner; public class LA2a { /** * Number of digits in a valid value sequence */ public static final int SEQ_DIGITS = 10; /** * Error for an invalid sequence * (not correct number of characters * or not made only of digits) */ public static final String ERR_SEQ = "Invalid sequence"; /** * Error for...
DESCRIPTION: You will be given a 2-D string array, called matrix. The array has an unknown number of cells filled with data. Your goal is to iterate through the 2-D array and keep a count of how many cells contain the string "Angela". INPUT: All input has been handled for you: A filled 2-D string array. PROCESSING: Determine the number of rows in the array matrix Determine the number of columns in the array matrix Use nested loops to iterate...
IT Java code In Lab 8, we are going to re-write Lab 3 and add code to validate user input. The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy level for a given height. The formula is as follows: bmi = kilograms / (meters2) where kilograms = person’s weight in kilograms, meters = person’s height in meters BMI is then categorized as follows: Classification BMI Range Underweight Less...
PrintArray vi Create a class called PrintArray. This is the class that contains the main method. Your program must print each of the elements of the array of ints called aa on a separate line (see examples). The method getArray (included in the starter code) reads integers from input and returns them in an array of ints. Use the following starter code: //for this program Arrays.toString(array) is forbidden import java.util.Scanner; public class PrintArray { static Scanner in = new Scanner(System.in);...
read the code and comments, and fix the program by INSERTING the missing code in Java THank you please import java.util.Scanner; public class ExtractNames { // Extract (and print to standard output) the first and last names in "Last, First" (read from standard input). public static void main(String[] args) { // Set up a Scanner object for reading input from the user (keyboard). Scanner scan = new Scanner (System.in); // Read a full name from the user as "Last, First"....