If_Else_Example
import "dart:io";
class Student {
var sname, sroll, sage;
void getData(String s, int r, int a) {
sname = s;
sroll = r;
sage = a;
print("Below are your subjects : \nMaths\nEnglish\nHindi\n");
print("How many marks you have got in Maths ? : ");
var mathsMark = stdin.readLineSync();
if(int.parse(mathsMark!) <= 33) {
print("Sorry, You are Fail in Maths Subject");
} else if(int.parse(mathsMark) > 33 && int.parse(mathsMark) < 50) {
print("Good, Your Maths mark is between 33 to 50");
} else if(int.parse(mathsMark) > 50 && int.parse(mathsMark) < 70) {
print("Very Good, Your Maths mark is between 50 to 70");
} else if(int.parse(mathsMark) > 70) {
print("Excellent, You have distinctive in Maths Subject, Congratulations!");
print("How many times have you attempted Maths Exam to get distinction ? : 1 OR 2 OR more...");
var dist = stdin.readLineSync();
if(int.parse(dist!) == 1) {
print("Wow, you are topper student");
} else if(int.parse(dist) >= 2) {
print("Ohk, don't mind, Your efforts were successful");
}
} else {
print("You were absent");
}
print("How many marks you have got in English ? : ");
var englishMark = stdin.readLineSync();
if(int.parse(englishMark!) <= 33) {
print("Sorry, You are Fail in Maths Subject");
} else if(int.parse(englishMark) > 33 && int.parse(englishMark) < 50) {
print("Good, Your Maths mark is between 33 to 50");
} else if(int.parse(englishMark) > 50 && int.parse(englishMark) < 70) {
print("Very Good, Your Maths mark is between 50 to 70");
} else if(int.parse(englishMark) > 70) {
print("Excellent, You have distinctive in Maths Subject, Congratulations!");
print("How many times have you attempted Maths Exam to get distinction ? : 1 OR 2 OR more...");
var dist = stdin.readLineSync();
if(int.parse(dist!) == 1) {
print("Wow, you are topper student");
} else if(int.parse(dist) >= 2) {
print("Ohk, don't mind, Your efforts were successful");
}
print("Your Total Marks is : ${int.parse(mathsMark) + int.parse(englishMark)}");
print("Your Average Marks is : ${(int.parse(mathsMark) + int.parse(englishMark))/2}");
} else {
print("You were absent");
}
}
}
void main() {
Student student = new Student(); //Creating object of class
print("Please Enter your Name : ");
var name = stdin.readLineSync();
print("Please Enter your Roll Number : ");
var roll = stdin.readLineSync();
print("Please Enter your Age : ");
var age = stdin.readLineSync();
student.getData(name!, int.parse(roll!), int.parse(age!));
}
Comments
Post a Comment