Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Demonstrate to the instructor the successful completion of each program output.

ID: 3675519 • Letter: D

Question

Demonstrate to the instructor the successful completion of each program output. Have this sheet ready for instructor to sign. Hand to instructor to receive credit. This program will input 5 floating point values from the keyboard(thc numbers will vary from the example below). All Five numbers will be entered individually(at the keyboard) echoing each number to the output file. The file output should be on your Z: drive (or your pen drive) with the name of your three initials I with the dat extension. At the END of the file, your name should be on the third to the last line, Lab #101-7.1-A on the second to last line and CP 101 Spring 2016 on the last line. The Screen Output should appear as follows {replace z:RF.Sl.dat with the name of your file} The file output for the 5 numbers entered at the keyboard should be as follows: (Replace Ruth Schultz below with your name}

Explanation / Answer

#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
float num;

//Creates an instance of ofstream, and opens example.txt
ofstream oFile ("Z:\RES1.dat", ios::app );
  
cout<<"Writing data to Z:RES1.data file: "<<endl;
// reading user input
for(int i=1; i<=5; i++){
   //reading from user
   cout<<"Enter Number "<<i<<" :";
   cin>>num;
  
   // writing to file
   oFile<<num<<endl;
  
   }
  
   oFile<<"Ruth Schiltz"<<endl; // replace with your name
   oFile<<"Lab #101-7.1-A"<<endl;
   oFile<<"Cp 101 Spring 2016"<<endl;
  
// closing output file
oFile.close();
  
cout<<"The data above is now in the filr Z:RES1.dat"<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote