Write a java program that reads a file (names as textfile) uploaded with assignment and displays the words of that file as a list. Then display the words in reverse order. Then display them with all plurals (ending in "s") capitalized. Then display them with all plural words removed.
*******************************************Java Program***********************************
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;
public class StringFormat {
public static void main(String[] args) throws Exception{
// for getting input from text file
Scanner sc =new Scanner(new File("textfile.txt"));
ArrayList<String> words= new ArrayList<>();
//checking input for next string
while(sc.hasNext())
{
String str=sc.next();
words.add(str);
}
//printing words
System.out.println("Printing words :");
for(String word: words) {
System.out.println(word); //printing list of words
}
//words in reverse order
System.out.println("Words in reverse order :");
for(int i=words.size()-1;i>=0;i--){
System.out.println(words.get(i));
}
//getting plurals
System.out.println("Plural words :");
for(String word: words) {
if(word.charAt(word.length()-1)=='s') {
System.out.println(word);
}
}
//removing plural
System.out.println("Without plural : ");
for(String word: words) {
if(word.charAt(word.length()-1)!='s') {
System.out.println(word);
}
}
}
}
*************************************************Output***********************************
Printing words :
Reader
Player
Antivirus
Robotics
Games
Mobile
Words in reverse order :
Mobile
Games
Robotics
Antivirus
Player
Reader
Plural words :
Antivirus
Robotics
Games
Without plural :
Reader
Player
Mobile
****************************************************************
My text file is:
Reader Player Antivirus Robotics Games Mobile
Write a java program that reads a file (names as textfile) uploaded with assignment and displays...
Write a Java program that reads words from a text file and displays all the non-duplicate words in ascending order. The text file is passed as a command-line argument. Command line argument: test2001.txt Correct output: Words in ascending order... 1mango Salami apple banana boat zebra
Create a java program that reads an input file named Friends.txt containing a list 4 names (create this file using Notepad) and builds an ArrayList with them. Use sout<tab> to display a menu asking the user what they want to do: 1. Add a new name 2. Change a name 3. Delete a name 4. Print the list or 5. Quit When the user selects Quit your app creates a new friends.txt output file. Use methods: main( ) shouldn’t do...
In C write a text analyzer program that reads any text file. The program displays a menu that gives the user the options of counting: • Lines • Words • Characters • Sentences (one or more word ending with a period) • or all of the above Provide a separate function for each option. At the end of the analysis, write an appropriate report.
( IN JAVA): Write a program that reads each line in a file, and writes them out in reverse order into another file. This program should ask the user for the name of an input file, and the name of the output file. If the input file contains: Mary had a little lamb Its fleece was white as snow And everywhere that Mary went The lamb was sure to go Then the output file should end up containing: The lamb...
IN JAVA. Write a program that reads a file (provided as attachment to this assignment) and writes the file to a different file with line numbers inserted at the beginning of each line. For example if file input is: This is a test File output should be 1. This is a test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BELOW FROM NOTEPAD FILE. This file contains lines of text to determine if you can properly read and write from a file.
Q1. CLO: (5 points) Write a java program that reads 10 words from the keyboard then place them in an array. Display the array elements in reverse order, and then count and print the number of times a word appears in that array. The user shall insert the word from the keyboard.
Write a program that reads k integers and displays their sum. Write a program that reads k values representing family income from the keyboard and place them into the array. Find the maximum income among these values. Count the families that make less than 10 percent of the maximum income. (JAVA)
Write a Java program called EqualSubsets that reads a text file, in.txt, that contains a list of positive and negative integers (duplicates are possible) separated by spaces and/or line breaks. Zero may be included. After reading the integers, the program saves them in a singly linked list in the same order in which they appear in the input file. Then, without changing the linked list, the program should print whether there exists two subsets of the list whose sums are...
Max3.java: Write a program that reads 10 integers and displays top 3 records (i.e., the largest three elements). Please consider the extreme case when all integers are negative. For instance, by given -1, -2, …, -10, the display will be -1, -2, and -3.
Write a Java program called Histogram.java that displays a list of distinct characters in an input tile and the occurrence of each eharacte. Your iogram should 1ead an input file name from a use. After that, your program should read characters in the file and display a list of distinct characters and their occurTeces. Finally, your program should draw a veril bafo the occuences For the assignment, your program has.to display the result exactly as the sample run. For instance,...