Program Purpose Using Visual Studio 2017 create a CLR console application. Creat
ID: 3594229 • Letter: P
Question
Program Purpose Using Visual Studio 2017 create a CLR console application. Create a program plan and then convert it into C++statements Practice debugging, declaring variables, type casting, formatting output, if statements and input loutput to from the console window and files, input validation, and while loops Always bring to class 1. Gaddis' book, How-to handouts from Canvas and your class notes. 2. This assignment sheet&the; grade sheet for this lab already printed out. 3. USB Flash drive(s) or other storage media. Mandatory Instructions Many spy codes are based on translating information from one representation to another. So for example, if I have a code that is of length 3, I could generate a corresponding picture. We are going to make a very simplified code translation program. You will read in an unknown number of integers from a data file "labll input.txt. "The data will be organized in the file so that there is one integer per line. Last integer will be -1 which will indicate end of data file. Program should end when this value is read. DO NOT count how many lines of data there are in the file!!! For each integer that you read from the data file, display a list of“*"s So if the number read is 4, the program would display on one line. Display " for even numbers and "S" for odd numbers. The output should be the displayed"s. Name of the output file should be "labll output.txt. Converting integers to a list of " or "S” 1 Check each integer to see ifit is>0. If yes, use a while loop to display the indicated number of characters 2. Otherwise if the integer is0 then only output a blank line 3. Otherwise if the integer is -1 convert the integer to a positive number and use the same loop as for (1) to display the "s or "'S's DO NOT write a separate loop for this case!!! s$$ $5$$$ ssss$$s St Declare all variables and constants that your program uses at the beginning of your program. 2. Your program should include two types of comments: a. Program banner // File Name LastF Labl1.cppExplanation / Answer
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
int x;
infile.open("lab11_input.txt");
outfile.open("lab11_output.txt");
while(infile>>x && x!=-1)
{
x=x>0?x:-1*x;
while(x--)
outfile<<"*";
outfile<<endl;
if(x==0)
outfile<<endl;
}
return 0;
}
This is code is working perfectly fine but you should add the comments that are required by your institute and make sure that lab11_input.txt is in the same directory in which you will have this code's file.
If you like this answer please give it a thumbs up and leave a nice comment also.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.