Question
Create an input file with nano lab04bin.txt 12 123 1234 12345 123456 1234567 12345678 123456789 Implementation Detail 1 : Remember that an integer divided by
Create an input file with nano lab04bin.txt
12
123
1234
12345
123456
1234567
12345678
123456789
Implementation Detail 1: Remember that an integer divided by an integer is of type integer. Make sure you use at least one decimal point in your division (like 1.0/9) or double(numerator)/denom
Implementation Detail 2: The default for the cout of a double is 5 places of accuracy. If you want to increase that you would use setprecision. Use setprecision (20)
my teacher wants us to implement above details to this program below:
#include
#include
using namespace std;
int main()
{
ifstream infile("in.txt");
ofstream outfile("out.txt");
bool done = false;
int menu = 3, item;
cout << "Your Name\tYour ID ";
while (!done)
{
cout << "1. Read from and write to file ";
cout << "2. Exit ";
cin >> menu;
switch (menu)
{
case 1:
while (infile >> item)
{
cout << "number:" << item << endl;
for (int i = 1; i < 5; i++)
{
cout << item + i << "\t";
outfile << item + i << "\t";
}//for
cout << endl;
outfile << endl;
}//while
infile.close();
outfile.close();
cout << "done. ";
break;
case 2:
done = true;
break;
default:
break;
}//switch
}//while
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started