-
Notifications
You must be signed in to change notification settings - Fork 0
/
9.cpp
89 lines (66 loc) · 1.93 KB
/
9.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
@Author: Amritanshu Sikdar
Session: 2018-'19
Repository: https://github.com/amritanshusikdar/CS30PracticalQuestion
*/
// To assign stream according to the given criteria
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class student
{
private:
char name[20];
int roll;
int marksOf5;
public:
char stream[20];
void input()
{
cout << "Name: ";
gets(name);
cout << "Roll number: ";
cin >> roll;
cout << "Marks of 5 Subjects(Total): ";
cin >> marksOf5;
cout << '\n';
}
void assignStream()
{
int percentage = marksOf5/5;
if(percentage >= 96 && percentage <= 100)
strcpy(stream,"Computer Science");
else if(percentage >= 91 && percentage <= 95)
strcpy(stream, "Electronics");
else if(percentage >= 86 && percentage <= 90)
strcpy(stream, "Mechanical");
else if(percentage >= 81 && percentage <= 85)
strcpy(stream, "Electrical");
else if(percentage >= 76 && percentage <= 80)
strcpy(stream, "Chemical");
else if(percentage >= 71 && percentage <= 75)
strcpy(stream, "Civil");
else // Checking if marks entered doesn't exceed the given range or limit
{
cout << "Marks out of range, Please reenter!\n";
input();
assignStream();
}
}
void display()
{
cout << "Name: " << name << endl;
cout << "Roll number: " << roll << endl;
cout << "Stream assigned: " << stream << endl;
}
};
void main()
{
clrscr();
student student;
student.input();
student.assignStream();
student.display();
getch();
}