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

Create a program in either C++, C#, or Visual Basic that does the following: 1)

ID: 3692747 • Letter: C

Question

Create a program in either C++, C#, or Visual Basic that does the following: 1) Displays some information on the screen 2) Attempts to open a non existent text file on the local hard drive 3) An exception handling routine should take over The exception handling routine must display a message on the screen - File does not exist - Should I create the file or exit the program If create the file is selected - the exception handling routine should create the file and allow the program to continue processing by: a) opening the file b) displaying a message - File opened successfully on the screen Otherwise a graceful termination of the program should be performed

Explanation / Answer

main() {

// A simple C++ program

int x, y, sum;
cout << "A program which adds two integers ";
cout << "Enter 1st integer: ";
cin >> x;
cout << "Enter 2nd integer: ";
cin >> y;
sum = x + y;
cout << "Sum is " << sum << endl;
return 0;
}

=================================================================

#include <iostream.h> preprocessor directive(s)

main() {

// A simple C++ program

int x, y, sum;
cout << "A program which adds two integers ";
cout << "Enter 1st integer: ";
cin >> x;
cout << "Enter 2nd integer: ";
cin >> y;
sum = x + y;
cout << "Sum is " << sum << endl;
return 0;
}

=================================================================

program body Sample output (text in red is entered by user): A program which adds two integers
Enter 1st integer: 3
Enter 2nd integer: 4
Sum is 7
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