Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Write a program that asks a user for a file name and prints the number of characters, words, and lines in that file.
the FileCounter class.
import java.io.FileReader; import java.io.IOException; import java.util.Scanner; import javax.swing.JFileChooser; /** This class prints a report on the contents of a file. */ public class FileAnalyzer { public static void main(String[] args) throws IOException { JFileChooser chooser = new JFileChooser(); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { FileReader reader = new FileReader(chooser.getSelectedFile()); Scanner fileIn = new Scanner(reader); FileCounter counter = new FileCounter(); counter.read(fileIn); fileIn.close(); System.out.println("Characters: " + counter.getCharacterCount()); System.out.println("Words: " + counter.getWordCount()); System.out.println("Lines : " + counter.getLineCount()); } } }
import java.util.Scanner; /** A class to count the number of characters, words, and lines in files. */ public class FileCounter { /** * instance variables */ //your code here... /** Constructs a FileCounter object. */ public FileCounter() { //Your code here . . . } /** Processes an input source and adds its character, word, and line counts to this counter. @param in the scanner to process */ public void read(Scanner in) { while (in.hasNextLine()) { String line=in.nextLine(); //Your code here. . . } } /** Gets the number of words in this counter. @return the number of words */ public int getWordCount() { //Your code here. . . } /** Gets the number of lines in this counter. @return the number of lines */ public int getLineCount() { //Your code here . . . } /** Gets the number of characters in this counter. @return the number of characters */ public int getCharacterCount() { //Your code here . . . } }
Write down java application named GoTooFar which declares the array of 5 integers and stored five values in array. write try block in which you loop to show each successive element of array.
Write down a Java program for the furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate price of table manufactured with chosen wood.
Write code that creates an array named odds and stores all odd numbers between -6 and 38 into it using a loop. Make the array's size exactly large enough to store the numbers.
Part 1: Create an abstract class named Element that holds properties of elements, including their symbol, atomic number, and atomic weight. Include a constructor that requires values for all three properties and a get method for each value.
Construct a set of classes for a college to use in many student service and personnel applications. Classes you require to design include following:
Suppose that customer inter-arrival times are exponentially distributed and service times are normally distributed. Create simulation by java language for this problem and view all parametre?
client server monitoring system project design. The server adminstation can send messages to the clients and DESIGN WITH JAVA NETBEANS AND GUI.
Implementation of memory management
Create and execute a stringed musical instrument class.
Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows ..
Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..
Write a program that simulate n rolls of six-sided die and displays the frequency of occurrence of each side and What is the most likely method signature of the "parseInt() - TNE60003
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd