Asked by Anonymous
Show how you would read the status of 100 students and then print the total number of students who are married, single, widowed, divorced.
Answers
Answered by
Steve
perl code:
foreach my $i (1..100) {
my $status = <STDIN>;
chomp $status;
$count{$status}++;
}
print "STATUS COUNT\n";
foreach my $key (sort keys %count) {
print "$key: $status{$key}\n";
}
foreach my $i (1..100) {
my $status = <STDIN>;
chomp $status;
$count{$status}++;
}
print "STATUS COUNT\n";
foreach my $key (sort keys %count) {
print "$key: $status{$key}\n";
}
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.