C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 8.5, Problem 3E

a.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare object ofofstream.
  • Create a statement to open the given file “polar.dat”.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • Read data from the program and write data to the file.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of this program is to create the “polar.dat” file and tostore the given data in the file.

b.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare an object ofofstream.
  • Create a statement to open the given file “polar.dat”.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • Display message to the user to enter the input.
  • Read data from the user and write data to the file.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of this program is to modify the program code given in part (a), so that the program can accept input from user and append the accepted data into the “polar.dat” file.

c.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare twoobjects forofstream and ifstream.
  • Create two open statementsfor “polar.dat” and “xycord.dat” file.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • Use while loop to read the file.
  • Calculate x and y coordinate, by using the below given formula:

  x=r(cosθ)y=r(sinθ)

  • int main() function is used to perform all the task.
  • Close both the files.

Program Description: The main purpose of this program is to modify the program code given in part (a), so that the program can calculate x and y coordinate and store the calculated data in the “xycord.dat” file.

Blurred answer
Students have asked these similar questions
(C++ Language) Create a function that writes to a file named Inventy.txt the information of 8 items. Ask the user for the item's name, the item's quantity in storage, and the item's price and write it to the file. Create a function that reads the file and items' quantity and price to two different arrays. Create a function that computes the subtotal of each item. Implement all functions inside the main program and the computed value should be displayed with the item's name.
(C ONLY) The program expects the name of an input file and an output file to be given by the user. If the user does not input any names, default file names should be used, such as input.txt and output.txt. The input files have lines which look like this: 3 Tester College; 1909 33001 The first number represents the rank; it is followed by the school name, year founded, and approximate number of students. Read the list of colleges into an array of structures. You may assume that the maximum size of a college name string is 64. The program should use either the insertion sort algorithm or the selection sort algorithm to sort the array in descending order by rank. Display any k consecutive schools requested by the user. For instance, if the user enters 12, the program displays the first 2 schools in a readable format of your choice. If the user enters 15, the program displays the first five schools, if the user enters 2 7, display 7 schools beginning with the one at index 1 (2 - 1), and so…
(Q. Write a program that will read a file from the user and writes its content in another file such that each line contains only 8 words. Coding language python  Don't use pointers and arrays keep the program as simple as possible (beginner's level) Paste the screenshots of full program with output) inputfile = input('Enter filename to read: ') outputfile = input('Enter filename to write: ') f = open(inputfile,'r') f1 = open(outputfile,'w') for lines in f:     f1.writelines(lines) f.close() f1.close() ***write comments on each line of the above written program and make changes in it with accordance to question if anything is wrong and also check if the underlined part of question is solved in program or not
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License