0

I am getting lots of error messages from this program. What am I not doing. I followed the suggestions in my book as well as from fell dani members, yet I am still not able to get this program working. It is suppose to add, average, find the smallest and largest number, product of three numbers. I am so lost. Please tell me that this will get easier. If anyone can help me with this code, please do. Also if the is anywhere out there on the web where I can get more help, add that too. It will be greatly appreciated. This is a homework assignment that is due on 9/10 I would really like to know what I am doing by then so that I can catch all of the other concepts that I am sure will be coming my way. This seems so simple....yet I feel so dumb. Please help

Attachments
// Playing with Integers Program
// Description: adds, sum, averages, compares, and gives product of three integers
// by: Robin Howell (jahowell01@aol.com)
#inclue <iostream.h> // allows program to perform input and output

using std:cout; // program uses cout
using std:cin; // program uses cin
using std; endl; // program uses endl

// function main begins
int main()
{

	int number1;// First number user will enter
	int number2; //Second number user will enter
	int number3; //Third number user will enter
	int sum; //The sum of number1 + number2 + number3
	int prod; // The product of number1 * number2 * number3
	int avg; // The average of number1 + number2 + number3 / 3
	char smal; // The smallest of all three integers
	char larg;// The largest of all three integers


		cout << "Enter first integer: "; // This will be displayed on the screen
		cin >> number1; //User will enter first integer

		cout << "Enter second integer: "; // This will be displayed on the screen
		cin >> number2; // User will enter second integer

		cout << "Enter third integer: "; // This will be displayed on the screen
		cin >> number3; // User will enter third integer

		sum = number1 + number2 + number3; //This will calculate the three integers

		cout << "Sum is " << sum << endl; //This will be displayed and end this function

			// Comparison of three integers
	

			cout << "Enter three integers to compare: "; // This will be displayed on the screen
			cin >> number1 >> number2 >> number3: //User will enter three integers

			if ( number1 < number2 < number3)
				cout << number1 << "smallest" << number1 << endl; //Will display on the screen

		
			if ( number1 > number2 > number3)
				cout << number1 << "largest" << number1 << endl; //Will display on the screen

		
			if ( number2 < number1 < number3)
				cout << number2 << "smallest" << number2 << endl;// Will display on the screen

		
			if ( number2 > number1 > number3)
				cout << number2 << "largest" << number2 << endl;// Will display on the screen

		
			if ( number3 < number1 < number)
				cout << number3 << "smallest" << number3 << endl; //Will display on the screen

		
			if ( number3 > number1 > number2)
				cout << number3 << "largest" << number3 << endl; //Will display on the screen

				//Averaging program will begin
				

				cout << "Enter first integer; //This will display on the screen
				cin >> number1; //User will enter first integer

				
				cout << "Enter second integer: "; // This will be displayed on the screen
				cin >> number2; // User will enter second integer

				cout << "Enter third integer: "; // This will be displayed on the screen
				cin >> number3; // User will enter third integer

				avg = number1 + number2 + number3 / 3; //This will calculate the average of the three integers

				cout << "Average is " << avg << endl;// This will be displayed and end this function

					
					// Product program will begin
					
					cout << "Enter first integer: "; // This will be displayed on the screen
					cin >> number1; //User will enter first integer

					cout << "Enter second integer: "; // This will be displayed on the screen
					cin >> number2; // User will enter second integer

					cout << "Enter third integer: "; // This will be displayed on the screen
					cin >> number3; // User will enter third integer

					prod = number1 * number2 * number3; //This will calculate the three integers

					cout << "Product is " << prod << endl; //This will be displayed and end this function
					return 0; //This will terminate the program
}
3
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by SpS
0

most of the problems are typing errors -- such as using colon when semicolon is expected, and misspelled words. Using Dev-C++ I had to change the top like this: Note <iostream> without .h extension.

#include <iostream> // allows program to perform input and output

using namespace std; // program uses cout
//using std:cin; // program uses cin
//using std; endl; // program uses endl
0

Here Is Thr Corrected Version Of The File

Attachments
// Playing with Integers Program
// Description: adds, sum, averages, compares, and gives product of three integers
// by: Robin Howell (jahowell01@aol.com)
#include <iostream> // allows program to perform input and output

using namespace std;

// function main begins
int main()
{

	int number1;// First number user will enter
	int number2; //Second number user will enter
	int number3; //Third number user will enter
	int sum; //The sum of number1 + number2 + number3
	int prod; // The product of number1 * number2 * number3
	int avg; // The average of number1 + number2 + number3 / 3
	//char smal;// The smallest of all three integers
	//char larg;// The largest of all three integers


		cout << "Enter first integer: "; // This will be displayed on the screen
		cin >> number1; //User will enter first integer

		cout << "Enter second integer: "; // This will be displayed on the screen
		cin >> number2; // User will enter second integer

		cout << "Enter third integer: "; // This will be displayed on the screen
		cin >> number3; // User will enter third integer

		sum = number1 + number2 + number3; //This will calculate the three integers

		cout << "Sum is " << sum << endl; //This will be displayed and end this function

			// Comparison of three integers
	

			cout << "Enter three integers to compare: "; // This will be displayed on the screen
			cin >> number1 >> number2 >> number3; //User will enter three integers

			if ( number1 < number2 < number3)
				cout << number1 << "smallest" << number1 << endl; //Will display on the screen

		
			if ( number1 > number2 > number3)
				cout << number1 << "largest" << number1 << endl; //Will display on the screen

		
			if ( number2 < number1 < number3)
				cout << number2 << "smallest" << number2 << endl;// Will display on the screen

		
			if ( number2 > number1 > number3)
				cout << number2 << "largest" << number2 << endl;// Will display on the screen

		
			if ( number3 < number1 < number2)
				cout << number3 << "smallest" << number3 << endl; //Will display on the screen

		
			if ( number3 > number1 > number2)
				cout << number3 << "largest" << number3 << endl; //Will display on the screen

				//Averaging program will begin
				

				cout << "Enter first integer";
				cin >> number1; //User will enter first integer

				
				cout << "Enter second integer: "; // This will be displayed on the screen
				cin >> number2; // User will enter second integer

				cout << "Enter third integer: "; // This will be displayed on the screen
				cin >> number3; // User will enter third integer

				avg = number1 + number2 + number3 / 3; //This will calculate the average of the three integers

				cout << "Average is " << avg << endl;// This will be displayed and end this function

					
					// Product program will begin
					
					cout << "Enter first integer: "; // This will be displayed on the screen
					cin >> number1; //User will enter first integer

					cout << "Enter second integer: "; // This will be displayed on the screen
					cin >> number2; // User will enter second integer

					cout << "Enter third integer: "; // This will be displayed on the screen
					cin >> number3; // User will enter third integer

					prod = number1 * number2 * number3; //This will calculate the three integers

					cout << "Product is " << prod << endl; //This will be displayed and end this function
					return 0; //This will terminate the program
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.