List Info

Thread: how to show the number of the correct answers




how to show the number of the correct answers
user name
2006-11-13 22:08:40
hello i am a perl beginner and i need help. i dont know and
have no
idea on how to make a program for this,

the program should ask a user 5 questions. it should read
the answers
and shows the number of answers that were right.

example:

Please enter £ two times: ££
Correct!

Please enter $ four times: ***
Wrong!

*****

You got 4 correct answers.

I have already written a program for the  5 questions:

e.g.

print ("Please enter £ two times: ");
$pound = <STDIN>;
$correct = "Correct!";

if ($pound !~m/££/)
{
print("Wrong!n");
}
else
{
print("$correctn");
}

print("Please enter $ four times: ");
$dollar = <STDIN>;

if($dollar !~m/^($)$/)
(
print("Wrong!n");
}
else
{
print("$correctn");
}

my problem is i dont know on how it will read the answers
and shows the
number of answers that were right. i would really appreciate
any help.
thanks!


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Perl Programming" group.
To post to this group, send email to perl-programminggooglegroups.com
To unsubscribe from this group, send email to
perl-programming-unsubscribegooglegroups.com
For more options, visit this group at 
http://groups-beta.google.com/group/perl-programming
-~----------~----~----~----~------~----~------~--~---

how to show the number of the correct answers
user name
2006-11-14 03:13:31
Hi,

Hoping that I understood your problem right. I think the only thing needed is a variable which is incremented everytime an answer is correct.That will give the count of correct answers. See lines added in your mail below.

Or you can store the answers, check them later and count the number of correct answers.

Regards
Sumit

On 11/14/06, angel < angel_dsgsyahoo.com">angel_dsgsyahoo.com> wrote:

hello i am a perl beginner and i need help. i dont know and have no
idea on how to make a program for this,

the program should ask a user 5 questions. it should read the answers
and shows the number of answers that were right.

example:

Please enter £ two times: ££
Correct!

Please enter $ four times: ***
Wrong!

*****

You got 4 correct answers.

I have already written a program for the &nbsp;5 questions:

e.g.

print ("Please enter £ two times: ");
$pound = <STDIN&gt;;
$correct = "Correct!";

if ($pound !~m/££/)
{
print(&quot;Wrong!n&quot;);
}
else
{
print("$correctn")$Corans++;
}

print(&quot;Please enter $ four times: ");
$dollar = <STDIN&gt;;

if($dollar !~m/^($)$/)
(
print("Wrong!n");
}
else
{
print(";$correctn&quot;); $corans++;
}

my problem is i dont know on how it will read the answers and shows the
number of answers that were right. i would really appreciate any help.
thanks!






--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "Perl Programming" group.
To post to this group, send email to perl-programminggooglegroups.com
To unsubscribe from this group, send email to perl-programming-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/perl-programming
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )