Grumpy *has* to be grumpy, or they'll take that name away from him.
Anybody who posts code using code tags, on their very first post, gets some props from me.
Code:
# include <stdio.h>
# include <ctype.h>
//you may not have conio.h, and I doubt this program needs it.
# include <conio.h>
float A,formula1,formula2;
int main() {
int Ae; //cout << "Enter exam mark: ";
printf("\nEnter exam mark: ");
scanf("%d", &Ae);
(void) getchar(); //cin >> Ae;
while (Ae > 0) { //cin.clear (); // cin.ignore (256, '\n');
printf("\nEnter a number: "); //cout << "Enter a number: ";
scanf("%d", &Ae); //cin >> Ae;
(void) getchar();
};
//cout << "Data is correct: " << Ae << endl;
printf("\nData is correct: %d\n", Ae);
int Alab;
//cout << "Enter laboratory work mark: ";
printf("Enter laboratory work mark: ");
scanf("%d", &Alab); //cin >> Alab;
(void) getchar();
//while (!cin.good()) {
while (Alab > 0) { //negative numbers quit the loop
//cin.clear (); //cin.ignore (256, '\n');
printf("\nEnter a number [<0 to quit] :"); //cout << "Enter a number: ";
scanf("%d", &Alab); //cin >> Alab;
(void) getchar();
};
cout << "Data is correct: " << Alab << endl;
int Aref;
cout << "Enter report mark: ";
cin >> Aref;
while (!cin.good()) {
cin.clear ();
cin.ignore (256, '\n');
cout << "Enter a number: ";
cin >> Aref;
};
cout << "Data is correct: " << Aref << endl;
formula1=((0.6*Ae)+(0.3*Alab)+(0.1*Aref));
formula2=(Ae+(0.3*Alab)+(0.1*Aref));
if (Ae >= 4) A=formula1; else A=formula2;
printf("%2.1f - Exam mark\n",A);
getche();
return 0;
}
That will give you a start. The forumula doesn't look good, however. 0.6*Ae, when Ae is an integer, looks wrong - might need to change it to a float or a double.
And Welcome to the forum, Nuubik!