Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Write a code fragment where you read user’s entries from the keyboard into three variables - an item ID (int), item name (string), and item price (double), combine these variables, separated by commas, into a single string record and write this record to a text file. Make sure that the file was successfully opened for writing, and close the file when finished. Include all required pre-processor directives. Declare all variables as required.
Example of the input:
123
Keyboard and mouse
65.85
Example of the output in the text file:
123,Keyboard and mouse,65.85
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 3 images
Knowledge Booster
Similar questions
- Hello. How would I get def automated to read the opened text document and make a playlist with the specified time and genre. Example I want to randomly select blues songs that total as close to 20 minutes as possible. import save def automated(filename): try: print(filename) except FileNotFoundError: print('Document not found.') def main(): filename = '' print('-'*45) choice = '' while choice.upper() !='Q': print() if filename != '': print('Current file opened:', filename) print('0) Choose a file to open\t1) Automated song choice') print('Q) Quit') choice=input('Enter a choice: ') if choice == '0': print() filename = input('Enter file name: ') rfile =open(filename,'r') line_list =rfile.read() for word in line_list: words_list=word.split(' ') print(line_list) print(f"File {filename} opened.") elif choice == '1':…arrow_forwardPYTHON: I need to get the avg statement out of the loop so that the output prints correctly. Any suggestions. Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam…arrow_forwardI need to modify this code to be able to read from a file and write into a file. The program is working as it should but I need an example of how to change my input and accept a file instead.arrow_forward
- Add the ability to convert an entire message into Morse code, as well as the ability to handle a data file comprising numerous entries. Change your input validation code so that the user has an infinite number of opportunities to enter valid responses. Your program should run until the user selects the "quit" option from your menu. Add a menu option to provide the user the option of processing a data file. Add another way to exit the program. When your software starts, the menu should be the first item that appears. The menu format should be the same as in the Sample Output. Allow the user to make more menu selections until they select the option to exit. Before soliciting the user for a menu selection, always show the menu. Handle an incorrect menu option correctly. The user should have an infinite number of opportunities to enter a valid menu option. Validate the user's input for the number of words sent so that numbers less than one are not accepted. Allow the user an unlimited…arrow_forwardUsing Pythonarrow_forwardAll I need is the main.cpp file Programming Specifications: Task: Two files have been provided (wordcounter.h and wordcount.cpp). You must open a text file, read in each word until end of file, add each word to the WordCount library and print the report. Your program must request a filename of a text file that contains words to count. You must check to see if it is a valid file and issue an error message if not and request a new file name until a valid one is entered. You must have at least one function that either passes in a parameter and at least one function that returns a value. You can have a single routine that does both. You must declare the class object properly, use AddWord() to add the word to the catalog and use PrintSummary() to produce the output. Design Considerations: The file will contain only words (no punctuation or special characters) less than or equal to 13 letters. There will be no limit to the number of words. You must open the file and read each…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY