1. How to detect when a person enters a number not a character = letter or non-numeric sign. So if he enters non-number i want the program to return him to the place where he entered it and ask him to enter the number again.
2. The program works great and calculates the average. The only thing i want is to add a delay time cuz when my program calculates the average it exits instantly(after 0.5 secs or something) so the person may not see the average.
Code:
Expand|Select|Wrap|Line Numbers
- # include <iostream>
- using namespace std;
- int main()
- {
- double n1 = 0.0;
- double n2 = 0.0;
- double n3 = 0.0;
- double average = 0.0;
- std:: cout << "This program will calculate the average of 3 numbers " << std::endl;
- cout << "Enter the first number: " << endl;
- cin >> n1;
- cout << "Enter the second number: " << endl;
- cin >> n2;
- cout << "Enter the third number: " << endl;
- cin >> n3;
- average = (n1 + n2 + n3) / 3;
- cout << "The average of the entered numbers is: " << average << endl << endl;
- system("PAUSE");
- return 0;
- }