You are on page 1of 1

import "dart:math";

import "dart:io";

class MathQuiz{

String ques;
double ans;

MathQuiz(String q, double a){


ques=q;
ans=a;
}

String getques(){
return ques;
}

double prompt(String text){


print(text);
double res=double.parse(stdin.readLineSync());
return res;
}

void main(){

List<MathQuiz> q=[
MathQuiz("10+2",12.0),
MathQuiz("2+2",4.0),
MathQuiz("4*5",20.0),
MathQuiz("5*3",15.0)
];

int score=0;

for(MathQuiz e in q){
double res=prompt(e.getques());
if(res == e.ans)
score++;
}

print("Your score is ${score} /${q.length}");

You might also like