Question

create a program that prompts the user for a file name and then provides the user...

create a program that prompts the user for a file name and then provides the user with the number of word in the file. The program should then allow the user to repeatedly specify a number and show that word in the file. (Note: Do Not use an array.)

please write in bsic comments so i can more easily understand

A test plan for the program. (How would you know the program is actually working properly?)

A shell program with stub functions (Including parameters and return values). also please explain what is a shell program with stub fuctions not in the program itself. In c++ Thank you

Homework Answers

Answer #1

Algorithm ::

Step1: Start
Step2: Declare the header files.
Step3: Openning the main function.
Step4: Open a file and initialize the values of line and word.
Step5: Declare seek and tell functions for jump and count.
Step6: If c=null || c=s then increment word count.
Step7: If c=s then increment line count.
Step8: Print the lines,words and size of a file.
Step9: Close the opened file.
Step10: Stop.


Source Code ::

// Header Files declaration

#include<iostream.h>
#include<fstream.h>
#include<conio.h>

// Opening of main function

int main()
{
ifstream fin("abc.txt"); //open a text file with .txt
int line=1,word=1,size; //It will not count the first word and the last line.So initial value is assigned to 1.
char c;


fin.seekg(0,ios::end); //bring the file pointer position to the end of the file.
size=fin.tellg(); //count the number of bytes till the current postion for file pointer.

fin.seekg(0,ios::beg); //bring the position of the file pointer to the begining of file.

while(fin)
{
fin.get(c);
if(c==' '||c=='s')
word++;

if(c=='s')
line++;
}

cout<<"Lines :"<<line<<"sWords :"<<word<<"sSize : "<<size<<"s";
fin.close(); //closing the open file.

return 0;

}

Output ::

/// *** Thank You ***///

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Python write a program that prompts the user for a file name, make sure the...
In Python write a program that prompts the user for a file name, make sure the file exists and if it does reads through the file, count the number of times each word appears and then output the word count in a sorted order from high to low. The program should: Display a message stating its goal Prompt the user to enter a file name Check that the file can be opened and if not ask the user to try...
Attached is a text file full of names. Write a program that prompts the user to...
Attached is a text file full of names. Write a program that prompts the user to type in a name. If the name appears in the list of names, the program prints a message indicating the name was found. If the name entered by the user is not in the database, the program prints a different message indicating the name was not found. The program will continue prompting the user and searching for names until the user enters "quit". The...
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
Write a program that prompts the user to enter the weight of a person in kilograms...
Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. (Note that 1 kilogram 52.2 pounds.) Add your name and comments to the .cpp page    Print your name on screen    Submit .cpp file
Create a program that prompts the user for an integer number and searches for it within...
Create a program that prompts the user for an integer number and searches for it within an array of 10 elements. What is the average number of comparisons required to find an element in the array? in java
Collapse Write a program that prompts the user to input a positive integer. It should then...
Collapse Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd integer is prime if it is not divisible by any odd integer less than or equal to the square root of the number.) Turn in: Your source code for with The name of your program as a comment at the top...
PLease code a C++ program that prompts a user to enter 10 numbers. this program should...
PLease code a C++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the 10 numbers and the average of the 10 numbers please use file i/o and input measures for Handling Errors in C++ When Opening a File
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
Create a C++ Program that prompts the user to enter a number and compute for the...
Create a C++ Program that prompts the user to enter a number and compute for the factorial value. SAMPLE OUTPUT: ENTER A NUMBER: -5 zero & positive numbers only!!! ENTER A NUMBER: 5 Factorial of 5 : 5*4*3*2*1 = 120 DO NOT USE FUNCTION FOR THIS PROBLEM. THANK YOU   
JAVA (Don't make it too complicated) Write a program that prompts the user for the name...
JAVA (Don't make it too complicated) Write a program that prompts the user for the name of a text file. The file should consist of a sequence of integers, one integer per line. The program will read in each line (using nextLine()), parse it as an int (using Integer.parseInt()), and report the number of values and their average. The average should be computed as a double. Your program should do some basic exception handling: (1) If the file cannot be...