if you have any doubts, please give me comment...
import java.util.*;
import static java.lang.System.*;
class FancyWordTwo{
private String[][] mat;
public FancyWordTwo(String s){
int size = s.length();
mat = new String[size][size];
for(int i=0; i<size; i++)
Arrays.fill(mat[i], " ");
for(int i=0;i<size; i++){
mat[0][i] = s.charAt(i)+"";
mat[i][0] = s.charAt(i)+"";
mat[i][size-1] = s.charAt(size-i-1)+"";
mat[size-1][i] = s.charAt(size-i-1)+"";
}
}
public String toString(){
String output = "";
for(int i=0; i<mat.length; i++){
for(int j=0; j<mat[i].length; j++){
output += mat[i][j];
}
output+="\n";
}
return output+"\n\n";
}
}
import java.io.File;
import java.io.IOException;
import java.util.*;
import static java.lang.System.*;
public class FancyWordTwoRunner{
public static void main(String[] args) throws IOException {
Scanner fileIn = new Scanner(new File("fancyword2.dat"));
int n = fileIn.nextInt();
FancyWordTwo fancy;
while(fileIn.hasNext()){
fancy = new FancyWordTwo(fileIn.next());
out.println(fancy);
}
fileIn.close();
}
}
Lab Description: Sample Data Read in one word at a time from the file and output...
Lab Description Sort all words by comparing the length of each word. The word with the smallest length would come first. If you have more than one word with the same length, that group would be sorted alphabetically Input: The data file contains a list of words. The first line in the data file is an integer that represents the number of data sets to follow Output: Output the complete list of words in order by length. Sample Data 10...
Trying to practice this assignment Argument list: the *yahoonews.txt Data file: yahoonews.txt Write a program named WordCount.java, in this program, implement two static methods as specified below: public static int countWord(Sting word, String str) this method counts the number of occurrence of the word in the String (str) public static int countWord(String word, File file) This method counts the number of occurrence of the word in the file. Ignore case in the word. Possible punctuation and symbals in the file...
Lab Description: Compare two Strings to see if each of the two Strings has the same first letter. Useful methods:: charAt) Sample Data: hello howdy one twO three two TCEA UIL State Champions ABC DEF Files Needed: StringFirstLetterCheck.java StringFirstLetterRunner.java Sample Output: hello has the same first letter as howdy one does not have the same first letter as two three has the same first letter as two TCEA does not have the same first letter as UIL State does not...
Java. (20 pts) Write a program that reads all the numbers from the file mynums.dat and prints out the sum of the positive values from the file. Assume that the file contains only numeric values. You must output an error if the file can't be opened. You must write the complete program and the output when the program runs successfully must conform exactly to the sample output. Bonus ( 5 pts). Output an error if the file contains non-numeric...
Ask the user for the name of a file and a word. Using the FileStats class, show how many lines the file has and how many lines contain the text. Standard Input Files in the same directory romeo-and-juliet.txt the romeo-and-juliet.txt Required Output Enter a filename\n romeo-and-juliet.txt has 5268 lines\n Enter some text\n 1137 line(s) contain "the"\n Your Program's Output Enter a filename\n romeo-and-juliet.txt has 5268 lines\n Enter some text\n 553 line(s) contain "the"\n (Your output is too short.) My...
java read integers from this binary file and when the value is 0 then stop reads and print its summation here is my code import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Random; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.FileInputStream; class Main { public static void main(String[] args) { String fname = "out.txt"; prepare(fname); ObjectInputStream inputStream = null; // create code here } public static void prepare(String fname) { ...
Get doubles from input file. Output the biggest. Answer the comments throughout the code. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Lab8Num1 { public static void main(String[] args) { //Declaring variable to be used for storing and for output double biggest,temp; //Creating file to read numbers File inFile = new File("lab8.txt"); //Stream to read data from file Scanner fileInput = null; try { fileInput = new Scanner(inFile); } catch (FileNotFoundException ex) { //Logger.getLogger(Lab10.class.getName()).log(Level.SEVERE, null, ex); } //get first number...
QUESTION The ReadFile class opens and reads a text file. The WriteFile class opens and writes to a file. Compile and run these programs. There are several ways to read/write text files. The examples shown here are just one way of achieving this. Look at the API for the BufferedReader class. The readline() method is a simple way to read the text file line by line. It returns null when the end of the file has been reached. https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html Look...
Lab Description : Write a program that will sum all of a numbers digits. You must use % for this lab to access the right most digit of the number. You will use /to chop off the right most digit. Sample Data 234 10000 Files Needed: DigitAdder.java JavaLoopLabRunner.java 9005 84645 8547 123456789 55556468 8525455 8514548 1212121212 Sample Output 14 27 24 45 34 35 15 12 import static java.lang.System.* public class DigitAdder public static int go( int num ) return...
Java Your boss has just put you in charge of updating the company's client contact list. This file contains records in the following format: id,first_name,last_name,email 1,Norry,Killby,nkillby0@photobucket.com Your job is to reformat each record as follows: last_name, first_name, email Killby, Norry, <nkillby0@photobucket.com> Starter Code: package contactlistupdater; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Paths; import java.util.Formatter; import java.util.Scanner; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class ContactListUpdater { private static final String INPUT_FILENAME = "contacts.txt"; private static final String OUTPUT_FILENAME = "updated-contacts.txt"; /** * Transforms a String...