Write a program that asks the user to enter a filename followed by a command. If the user enters the command "print", your program should print the contents of the file to the console exactly as it appears in the file. If the user enters the command "double", your program should read each number contained in the file and print the number doubled to a separate line on the console.
Note: Assume the input file contains only integer numbers separated by a space character. Also assume input file (number.txt file) contains: 1 2 3 4 5 6 7 8 9 10.
You may use the starter code provided:
Sample Input/Output:
Enter the input file name:
c:\\cpp\\number.txt
Enter the command 'print' to print the exact contents of the file to the console.
Enter the command 'double' to read each number from the file and print the doubled value to the console.
Enter the command 'exit' to exit from the program.
Please enter a command:
print
1 2 3 4 5 6 7 8 9 10
Enter the command 'print' to print the exact contents of the file to the console.
Enter the command 'double' to read each number from the file and print the doubled value to the console.
Enter the command 'exit' to exit from the program.
Please enter a command:
double
1 4 9 16 25 36 49 64 81 100
Enter the command 'print' to print the exact contents of the file to the console.
Enter the command 'double' to read each number from the file and print the doubled value to the console.
Enter the command 'exit' to exit from the program.
Please enter a command:
exi
Unknown Command.
Please try again...
Enter the command 'print' to print the exact contents of the file to the console.
Enter the command 'double' to read each number from the file and print the doubled value to the console.
Enter the command 'exit' to exit from the program.
Please enter a command:
exit
Process returned 0 (0x0) execution time : 30.888 s
Press any key to continue.