Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Retire.cpp : Defines the entry point for the console application. // program to convery years to retire // sumin Kang // 9/26/17 #include stdafx.h

// Retire.cpp : Defines the entry point for the console application.

// program to convery years to retire

// sumin Kang

// 9/26/17

#include "stdafx.h"

#include

#include

#include

#include

using namespace std;

int main()

{

//declare files

ifstream inFile;

ofstream outFile;

// declare constants and variables

string name;

int age;

int ageInRetire;

// open files

inFile.open("D:\ etire");

outFile.open("D:\ etire");

// get input from user

cout << "What is your name?";

getline(inFile, name);

cout << "How old are you?";

inFile >> age;

// perform calulations

ageInRetire = 27 + age;

// display results

outFile << " Well, " << name << " can retire in " << ageInRetire << " years.";

// close files

inFile.close();

outFile.close();

// freezen screen

string junk;

cout << " Press any keys to continue...";

cin >> junk;

return (0);

This is my homework guidline:

Modify your Retire.cpp program to accept its input from a disk file named "Retire.dat" and display the output to the screen. Then modify it again to send the output to a disk file name "retire.out".

And I did above code, and my inFile is retire.dat which is

Sumin 21

then I have a file will become outFile, but it is strange.

I have a result that

"Well, Sumin can retire in 48 years."

but my file's result is

Well, can retire in -858993433 years.

How do I fix it?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

1.6 Identify ways that country culture influences global business.

Answered: 1 week ago