# include <stdio.h>
# include <ctype.h>
# include <conio.h>
float A, formul1, formul2;
int main()
{
int Ae = 0;
printf("Enter exam mark: ");
scanf("%d", &Ae);
getchar();
while ( Ae < 1 || Ae > 10 )
{
printf("Enter a number(border from 1 to 10):");
scanf("%d", &Ae);
getchar();
};
printf("Data correct: %d\n", Ae);
int Alab = 0;
printf("Enter laboratory work mark: ");
scanf("%d", &Alab);
getchar();
while ( Alab < 1 || Alab > 10 )
{
printf("Enter a number(border from 1 to 10):");
scanf("%d", &Alab);
getchar();
};
printf("Data correct: %d\n", Alab);
int Aref = 0;
printf("Enter report mark: ");
scanf("%d", &Aref);
getchar();
while ( Aref < 1 || Aref > 10 )
{
printf("Enter a number(border from 1 to 10):");
scanf("%d", &Aref);
getchar();
};
printf("Data correct: %d\n", Aref);
formul1 =( ( 0.6*Ae ) + ( 0.3*Alab ) + ( 0.1*Aref ) );
formul2 = Ae;
if ( Ae >= 4 ) A = formul1; else A = formul2;
printf("%2.1f - Exam mark\n",A);
getche();
return 0;
}
So I started to rewrite this code and did some of the work, but then I got some problems and now i can't finish this work because of those problems. So I am going to add my code(not finished) for second work:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
#define N 25
int menu();
int main()
{
struct list
{
int nr;
char name[20], surname[20], exam_mrk[2], laboratory_mrk[2], report_mrk[2];
float mrk;
} student[N];
int i,j,x;
while (x != 4)
{
x = menu();
switch(x){
case 1: printf("blablabla");
getch();
system("cls");
break;
case 2: printf("Save information about students which includes: ");
printf("Student name, surname, marks, final mark");
printf("(according to the first code)");
printf ("provide opportunity to list all unsuccessful students ");
getch();
system("cls");
break;
case 3: printf("Fill the list please\n");
for(i=0; i<N; i++)
{
student[i].nr = i+1;
printf("\nEnter %d. student information\n", i+1);
printf("Name: ");
gets(student[i].name);
printf("Surname: ");
gets(student[i].Surname);
printf("Exam mark: ");
gets(student[i].exam_mrk);
printf("Laboratory work mark: ");
gets(student[i].laboratory_mrk);
printf("Report mark: ");
gets(student[i].report_mrk);
system("cls");
printf("List of students\n");
for(i=0; i<N; i++)
printf("%2d%15s%15s%2d%2d%2d%4.2f\n", student[i].nr, student[i].name, student[i].surname, student[i].exam_mrk, student[i].laboratory_mrk, student[i].report_mrk, student[i].mrk);
getch();
return 0;
case 4: for(i=0; i<N; i++)
{
if((student[i].mrk)<4)
printf("%2d%15s%15s%2d%2d%2d%4.2f\n", student[i].nr, student[i].name, student[i].surname, student[i].exam_mrk, student[i].laboratory_mrk, student[i].report_mrk, student[i].mrk);
}
getch();
system("cls");
break;
case 5:
return 0;
break;
default:
printf("You entered wrong symbol");
break;
printf("\n Any key to continue !! \n");
getch();
system("cls");
}
}
}
}
int menu()
{
int q;
printf("Menu\n");
printf("Choose operation:\n");
printf("1.Info about creator\n");
printf("2.Task terms\n");
printf("3.Start program\n");
printf("4.List all unsuccessful students\n");
printf("5.Quit\n\n");
scanf("%d",&q);
return q;
}
So, I have following problems:1. I can't figure out how to rewrite function from 1. task which calculates final mark in the second work(how to rewrite this - formul1 =( ( 0.6*Ae ) + ( 0.3*Alab ) + ( 0.1*Aref ) );
formul2 = Ae;
if ( Ae >= 4 ) A = formul1; else A = formul2;)
2. And the second problem is, i don't know rewrite code, to set restriction for entered symbols, that is, restrictions for numbers only
I would be very thankful if someone could help me with this, because without of these 2 things I can't finish my work, and the problem is that I can't figure these 2 problems out.


Sign In
Create Account

Back to top









