Write a program that asks the user for the name of a file, and an integer number. The program should display the first several lines of the file on the screen, and the number of lines should be equal to the integer entered by the user. If the number of lines the file has is less than the integer entered by the user, then the entire file should be displayed, with a message indicating the entire file has been displayed. When evaluating the peer submissions, please consider two cases to verify the program, with one case where the file has enough lines, and one case where the file does not have enough lines.

Question

 Write a program that asks the user for the name of a file, and an integer number. The program should display the first several lines of the file on the screen, and the number of lines should be equal to the integer entered by the user. If the number of lines the file has is less than the integer entered by the user, then the entire file should be displayed, with a message indicating the entire file has been displayed.

When evaluating the peer submissions, please consider two cases to verify the program, with one case where the file has enough lines, and one case where the file does not have enough lines.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Engineering

Programing

Related Computer Engineering Q&A

Find answers to questions asked by students like you.

Q: Explain the historical development of programming languages and compare Object Oriented Programming ...

A: Click to see the answer

Q: Java  What is the catch phrase?  What is a finally clause?   How do both catch and finally work in a...

A: Whether a new exception is thrown into a capture block or ultimately a block that will spread out of...

Q: RAID is a method to create live backups of physical hard disks but creating RAID will decreases the ...

A:   First let us understand what the RAID is 

Q: Amba Aambika and Ambalika have money in the ratio x:y:z. All go to market and spend money in ratio p...

A: Procedure followed: Declare variables to store ratios of having money as x,y, and z. Declare variab...

Q: someone that have the answere of this questions?

A: It is given that Allbest airlines have 100 planes. The planes breakdown on an average twice a year a...

Q: c. Discuss whether software development projects are more susceptible to Scope Creep than other type...

A: (c) It is essential that a functional specification is produced at the beginning, written in terms t...

Q: Your client owns a bookstore, and they need to process an input file containing the titles of all th...

A: The c++ program is written where it takes the input file and necessary commands are provided in the ...

Q: What is wrong with the following short Python code? It doesn't work! Give the appropriate correction...

A: lambda function: a lambda is a short form of the function and it is a small anonymous function call....

Q: Draw a singly linked list where each node contains a letter of your full name withoutconsidering any...

A: Hey, since there are multiple questions posted, we will answer first -three parts question. If you w...

Q: 4. 1. Develop an algorithm to arrange a set of numbers using heap sort technique. 2. Analyse time an...

A: Heapsort AlgorithmHeapsort(arr) buildMaxHeap(arr) for (int i = n - 1; i >= 0; i--) {         swap...

Q: Discuss about microcomputer with necessary diagram.

A: Microcomputer:- The microcomputer is a browser constructed as an embedded system on the basis of a m...

Q: public void enableselectors() { // need help -- make this code actually enable or disable the select...

A: The ask is to build the enable and the disable methods for the map of selectors of Category object k...

Q: What is the answer for following questions?

A: 1. To find the second largest element of the given array, first of all, sort the array.Compare the p...

Q: 1. Why do computers need to know the MAC address of the destination via the ARP packet?2. Can comput...

A: ARP stands for Address Resolution Protocol. When you try to ping an IP address on your local network...

Q: Differentiate the manually match transactions and Advanced Mode in Bank Feed  transactions in QuickB...

A: Click to see the answer

Q: Why Data Bus is bidirectional

A: Data bus is bidirectional :  It is a group of conducting wires which carries Data only. Data bus is ...

Q: Write an 8051 C program to send letters ‘M’, ‘D’, and ‘E’ to the 16x2 LCD.

A: 8051 Microcontroller : An 8-bit microcontroller basically designed by Intel having 40 pins DIP(Dual ...

Q: Develop the Java program for automate the admission process portal as mentioned below: Consider the...

A: Program: import java.io.*; import java.util.*; import java.util.Random; import java.util.ArrayList; ...

Q: Could you help me find a Python recursive function to determine the nth term of: a1=-1, an = 2n - an...

A: Step 1:- Note:-The given expression is a(n)=2*n-a(n)-1  through this ,it is not possible to calculat...

Q: How to get 8x1 by using 2  4x1 mux?

A: To make 8 x 1 MUX, we need two 4 x 1 MUX. A0,A1,A2,A3 are input lines to each 4 x 1 MUX. And S0 and ...

Q: How many bytes are allocated for each interrupt vector entry in the interrupt vector table

A: 4 bytes are allocated for each interrupt vector enty in the interrupt vector table located at bottom...

Q: The language is C++ 3. Write a program to calculate the factorial value of the inputnumber.Use the i...

A: The C++ program is written which will be user defined input of the function. The program uses the fo...

Q: RAID is a method to create live backups of physical hard disks but creating RAID will decreases the ...

A: For backups with applications like Int ego, Personal Back-up, or Time Machine Apple can be used with...

Q: Question 4: a) Which form of biometric technology do you prefer for identification purposes: fingerp...

A: Commonly used biometric technology Fingerprint biometrics is based on the recognition of specific p...

Q: 1.•  C# By who the programming language which In history to develop started? 2• C# Features what are...

A: Actually, C# is also a one of the programming language.

Q: Help please

A: Solution is in Step 2.

Q: True or False: If we declare a LinkedList but don't instantiate it, we can't add things to it withou...

A: In the linked list structure, the elements are linked to one another. This linking happens when the ...

Q: Write a function replace_head_tail that takes a string str1 and replaces the first X and last Y char...

A: Please find the answer below :  

Q: one t1 line is the equivalent of how many number of POTS multiplexed lines

A: Actually, multiplex is a device which allows several analog and digital signal.

Q: You must use an STL container (such as list or vector) for this assignment; solutions not using an S...

A: #include <iostream> #include <cmath> #include<vector> using namespace std; int mai...

Q: Q. With meaningful examples of your own write down usage of all the a. File & directory commands b. ...

A: Actually, program is a executable software that runs on a computer.

Q: Given a positive integer, N, the ’3N+1’ sequence starting from N is defined as follows: If N is an ...

A: The main objective of the C++ program, main. cpp is to prompt the user to enter a value and read a v...

Q: Introduce about Network security, Network attacks and their impacts on the society. please explain p...

A: Actually, network is a all devices communicate with other.