#include <iostream>
#include <cstdlib> // for atoi
using namespace std;
int main(int argc, char* argv[]) {
int sum = 0;
try {
for (int i = 1; i < argc; ++i) {
// Check if the conversion from string to integer is successful
char* end;
long val = strtol(argv[i], &end, 10);
if (*end != '\0' || end == argv[i]) throw invalid_argument("Invalid input");
sum += val;
}
double average = static_cast<double>(sum) / (argc - 1);
cout << "The sum is " << sum << "." << endl;
cout << "The average is " << fixed << setprecision(1) << average << "." << endl;
} catch (const invalid_argument& e) {
cout << "Incorrect Input!" << endl;
return 1; // Non-zero return value to indicate error
}
return 0; // Success
}