Write a Java program that reads in a word from the user and outputs each character of the word on a separate line. For example, if the user enters the input "Joe", your program should output:
J o e
You need to use a for-loop.
// code for the given string to character wise printing in java
import java.util.Scanner;
public class WordtoLetters{
public static void main(String []args){
// to read a word
Scanner input=new Scanner(System.in);
String word=input.next();
//for loop to print character wise
for(int i=0;i<word.length();i++)
System.out.println(word.charAt(i));
}
}
output obtained
$javac WordtoLetters.java $java -Xmx128M -Xms16M WordtoLetters h e l l o
Write a Java program that reads in a word from the user and outputs each character...
Write a Java program that reads in a positive integer from the user and outputs the following triangle shape composed of asterisk characters. For example, if user enters 5 as the input, then your program should display the following shape: ***** **** *** ** *
Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...
Using Java write a program that takes a string input from the user and then outputs the first character, then the first two, then the first three, etc until it prints the entire word.
Write a Java program that reads a word and prints its bigrams substrings. A character bigram is defined as a continuous sequence of two characters in a word. For example, if the user provides the input "rum", the program prints ru um Hint: 1. set two pointers, one always moves from the beginning of the string and the other moves from i+2, in which i is the current position of the first pointer. 2. print an error message if the...
please I need help with the question:
Problem: Write a C++ program that reads each character
from a user input, extracts the character if it is a digit, and
calculates the sum of all the digits. The program stops reading the
user input when the new line character ‘\n’ is encountered. For the
output of the program, you should print each digit extracted from
the user input and the sum of all the digits.
(*The main difference between “cin >>...
Write a Java program that reads in 5 words from the user and stores these words in a String array. Then your program needs to print 2 lines of output with the following information: All words are in reverse order (based both on content and order). Every word at an even index of the array (i.e., indices 0, 2, and 4). For example, if user inputs "ABC", "DEF", "TY", "JK", and "WE". Then your program should output the following two...
In this exercise, write a complete Java program that reads integer numbers from the user until a negative value is entered. It should then output the average of the numbers, not including the negative number. If no non-negative values are entered, the program should issue an error message. You are required to use a do-while loop to solve this problem. Solutions that do not use a do-while loop will be given a zero. Make sure to add appropriate comments to...
Write a program that takes in a line of text as input, and outputs that line of text in reverse. You may assume that each line of text will not exceed 50 characters. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Hey quit then the output is: ereht olleH уен Hint: Use the fgets function to read a string with spaces from the user...
Write a program that reads a char as an input from the keyboard and outputs whether it is a valid character to start an identifier. (Hint: look for a method in for the Character class.) Please do this in java.
Write a program that reads each word from A1.txt and check if it's a palindrome or not. Show your output in the file Bl.txt. The total number of words in the file can change. You must use c-string or character arrays. Using String datatype and strrev() function are not allowed in this problem. "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward." (Wikipedia) Sample Input: series madam Sample Output: yes