Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Grouping Names(strings) into Two Categories??
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sarah_xoxo




PostPosted: Sun Nov 03, 2013 6:21 pm   Post subject: Grouping Names(strings) into Two Categories??

can anyone please help me with this question in turing? I don't understand how to group strings. Any help is appreciated, thanks Smile


1) Write a program to divide a class of students in two groups: those whose last name begin with A to h and those that begin with I to Z. Ask each to enter their last name and then output which group they are in. (10 marks and 4 for documentation)
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Nov 03, 2013 6:50 pm   Post subject: RE:Grouping Names(strings) into Two Categories??

I notice you don't actually have to store anything, you just need to output the category. This makes it really, really easy. All you do is check the first letter of the name: If it's a to h, output "Group 1". If it's i to z, output "Group 2".

If it helps, you can compare characters to numbers. For example,
code:
if a > 5 then
    put "a > 5"
else
    put "a <= 5"
end if
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: