Thank you for looking at this.
SO my problem now is that the for loop won't run for the
amount given. it also wont do the find the sloution to the
the problem total = total + num1.
On the second half I can't get the while to quit with input.
also it will not at one to Even_Num?
*Author :
*Date :
*Course/Section : CSC110-???
*Program Description: This lab introduce repitions statments. Your
* Program will as the user for how many mubers to input. You will
* then code a FOR loop to add up the numbers. Display the sum and
* pause the screen. THEN your program will input an unknown number
* of positive integers. Count and display the number of even
* numbers. Enter a -1 to stop entering in numbers
*
*BEGIN Lab 04 - Repitions
* Init total to 0
* Input count of how many numbers to input
* FOR (Each number to input)
* Enter the number
* Add the number to the total
* END FOR
* Clear the screen
* Display the total
* Pause the screen
* Clear the screen
* Init count of even numbers to 0
* Input a positive number (or QUIT)
* WHILE (input number is not QUIT)
* IF (Input Number is even)
* Add 1 to count of even numbers
* END IF
* Get next input number or quit
* END WHILE
* Display the count of even numbers
*END Lab 04 - Repetition
********************************************************************/
#include <iostream>
#include <iomanip>
usingnamespace std;
void main()
{
//local constants
constint QUIT = -1;
//local variables
int Number;
int Num1;
int Num2;
int Total = 0;
int Even_Num;
int Count;
/**************************start main program*********************/
//Prompt for number input
cout << "\n\n\n\n\n\n\n";
cout << setw(50) << "------------------------------" << endl;
cout << setw(50) << " Enter an amount of numbers " << endl;
cout << setw(50) << "------------------------------" << endl;
cout << "\n" << setw(46) << "Amount: ";
cin >> Number;
for (Count = 0; Count > Number; Count++);
{
cout << setw(47) << "Enter first Number: " << endl;
cin >> Num1;
Total = Total + Num1;
}
cout << setw(50) << "Total: " << Total << endl;
system ("PAUSE");
system ("cls");
while (Even_Num != QUIT)
{
Total = Total + Num2;
cout << "Input Next Even Number Or -1 to Quit";
cin >> Num2;
if (Num2 % 2 == 0)
{
Even_Num ++;
}
cout << "Input Next Even Number Or -1 to Quit";
cin >> Num2;
}
system ("cls");
cout << "\n\n\n\n\n\n\n";
cout << setw(50) << "-------------------------" << endl;
cout << setw(50) << " Amount Of Even Number " << setw(3) << Even_Num << endl;
cout << setw(50) << "-------------------------" << endl;
}
//End main program
Yup You guys were right. Thank you so much. As for the system(cls) and system(Pause), when you say a pair of cin.ignore(?) what do you mean I think you're telling me to type cin.ignore(cls)? thank you so much again.
system("pause");
can be replaced with cin.ignore(); cin.ignore();
There is no real standard-library replacement for system("cls");, although maybe you could try:
1 2
for(int i = 0; i < 128; i++)
cout << endl;
We have good reasons for discouraging the use of system, by the way. If you check the Articles section of this forum, there's a stickied post about console programming with a link to why system() is "evil".