I need help with CHP 9 PC 10 in the book Starting out with java from control structures through data structures 3rd edition. The question states: "Write a program that asks the user for the name of a file. The program should display the number of words that the file contains." Thank you!
Code
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
String fileName;
System.out.print("Enter the filename: ");
fileName=scn.nextLine();
int count=0;
BufferedReader reader;
try
{
reader = new BufferedReader(new FileReader(fileName));
String line = reader.readLine();
while (line != null)
{
String word[]=line.split(" ");
count+=word.length;
line = reader.readLine();
}
reader.close();
System.out.println("\nTotal number of word in file "+fileName+" is
:"+count);
}
catch (IOException e)
{
System.out.println("\nFile with filename '"+fileName+"' not
found.");
}
}
}
output
data.txt

If you have any query regarding the code please ask me in the
comment i am here for help you. Please do not direct thumbs down
just ask if you have any query. And if you like my work then please
appreciates with up vote. Thank You.
I need help with CHP 9 PC 10 in the book Starting out with java from...
PLEASE HELP!!!I need help with the following JAVA PROGRAMS.
Please ready carefully. So this comes from tony
gaddis starting out with java book. I have included the screenshot
of the problems for reference. I need HELP implementing these two
problems TOGETHER. There should be TWO class files. One which has
TWO methods (one to implement problem 8, and one to implement
problem 9). The second class should consist of the MAIN program
with the MAIN method which calls those methods....
I need help writing the following java Java Method below. I just need a method to take a user inputted First or Last Name and return the associated phone number, thank you! import java.util.*; import java.io.*; class PhoneList { public static void main(String[] args) throws Exception { boolean loop = true; File file = new File("PhoneList_Data.txt"); FileWriter fw = new FileWriter(file, true); fw.write("PhoneList Data"); fw.write("\n" + "Last, First: 6041337567, 2181731566"); // do { } (loop) fw.close(); } //...
I need help on Java Swing, how to create a Java Swing program that can able to Display all the name list from the text file then Display the Longest name...
Starting out with Java: From control structures through objects, 1e Complete the programming challenge Chapter 13 #4 Make sure that you CREATE A MENU SYSTEM. The menu should have sub-menus for plans, phones, options, and a file menu that allows the user to exit the GUI. The total cost of the plan should be displayed and updated as the user makes menu choices.
JAVA We are learning about java databases in my highschool java class. I Need some help with it. Create a Java program (feel free to do it all in a main method) that works with a database that contains your 'Contractors' table (see the last exercise). Id (integer, primary key) CompanyName (varchar, 30 characters) Phone(varchar, 12 characters) ContactName(varchar, 30 characters) Rating (integer) OutOfStateService (boolean) # company name phone # Name rating Out of state service 1 Joe's Brewery 1111111111 Joe...
Class: Java
Book: Introduction To Java Programming 10th Edition,
Comprehensive by Daniel Liang
Problem:
****** Parse the text file by splitting on "[
\n\t\r.,;:!?(){}<>\"]", that is call the split method with
this parameter: For example, call contents.split("[
\n\t\r.,;:!?(){}<>\"]"), where contents is a String object
containing the contents of the text file.
Also, explain (in the comment block at the beginning of
the source file) two other approaches that could have been taken
for the problem (use of other data structures,...
I need help solving problem 9.16 from matlab for engineers holly moore 4th edition % 9.16 A store owner asks you to write a program for use in the checkout process. % The program should: % • Prompt the user to enter the cost of the first item. % • Continue to prompt for additional items, until the user enters 0. % • Display the total. % • Prompt for the dollar amount the customer submits as payment. % •...
Need the solutions for the following problem from Starting out with C++: From Control
Structures Through Objects - 8th edition
CH.11 Page 651 Programing challenges #12
Please send the solution codes to richardok24@gmail.com if you
can.
Hello, I need assistance with my assignment please in Visual Basic. Starting Out With Visual Basic Seventh Edition Chapter 5 Programming Challenge #1. Sum Of Numbers... page 370 Create an application that displays a form similar to the one shown in Figure 5-44. When the Enter Numbers button is clicked, the application should display the input box shown in Figure 5-45. The input box asks the user to enter a positive integer value. Notice that the default input value is...
I need help wrting a java program that creates an array with 20 randomly chosen integers. The program should prompt the user for an index of the array and display the corresponding element value. If the specified index is out of bounds,display the message "Out of Bounds".