Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
PROBLEM SET A
Part 1. General Rule: Choose and solve only 3 problems from the given problem set. Output must be similar
to the given sample shown here. Maximum of 100 points only.
Rubrics:
Nearness to the output
Algorithm/Logic (program flexibility)
Error Trapping
**for questions and clarifications please see your instructor.
Problem Set #1 (30 pts)
How do you know if you are matched with crush? Nowadays millennials use dating apps such as TINDER to
see if they match with someone. Back in the day, 90s kids will remember, the ultimate matching method is
the good old FLAMES. F.L.A.M.E.S stands for Friends, Lovers, Anger, Marriage, Engagement, and Soulmates.
You write the full name of two people, probably yours and that of your crush. Cross out the similar letters in
the names, and then total the number of the remaining letters from each name. You then count the
numbers against the acronym get a future prediction of your ‘relationship’ with the person. Didn't get the
result that you want per individual? Not to worry! Total the matched letters from each name and see your
ultimate prediction.
Input: a non-empty text composed only of uppercase letters of English alphabet. The length of the
text is less than 100.
Output: output each name and the corresponding future prediction of your relationship with the
person and the ultimate prediction for both names.
Sample Dialogue:
FLAMES
ROSALIE TOMO - 10 Marriage
MELVITO BARICAUA - 11 Engagement
- 21 Anger
Note: To get the equivalent prediction, count the number of cancelled letter or character in each name,
sum it up and get your ultimate prediction.
Example:
Enter your name: Rosalie Tomo
Who is your crush: Melvito Baricaua
Rosalie Tomo - Marriage
Melvito Baricaua - Engagement
- Anger
Enter your name: Jayrald Naraja
Who is your crush: Janelle Ayson
Jayrald Naraja - Lover
Janelle Ayson - Lover
- Marriage
Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
Problem Set #2 (20 pts)
A company wants to transmit data over the telephone but they are concerned that their phones may be
tapped. All of their data are transmitted as a four-digit number. They have asked you to write a program
that encrypts their data so that it can be transmitted more securely. Your program should read a four-digit
integer and encrypt it as follows:
**replace each digit by adding that digit to 7 Modulus 10. Then swap the first digit with the 3rd and swap
the 2nd with the fourth.
Input: Integer n, four digits only. (n<=10^9)
Output: Display the encrypted integer.
Example:
Enter four-digit number: 1234
The encrypted integer is: 0189
Enter four-digit number: 3991
The encrypted integer is: 6806
Enter four-digit number: 6582
The encrypted integer is: 5932
Problem Set #3 (20 pts)
The ABC computer company has an elaborate computerized system. Every employee who enter
should enter their computer code number. The computer determines if the employee is an
intruder, an officer, or a regular employee.
The computer code number is a four-digit number.
*if the first digit is even and the third is odd, the employee is a company officer.
*if the first digit is even and so with the third, the employee is a regular employee.
*otherwise, it is an intruder.
*when the second and the fourth digit are joined, they form the employee’s ID number.
Example:
Enter Code: 2345
Welcome, regular employee #35
Enter Code: 6731
Welcome, company officer #71
Enter Code: 3987
ALERT! ALERT! INTRUDER!
Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
Problem Set #4 (30 pts)
Positive and negative attitude are both contagious. All of us affect, in one way or another, the people
around us. This influence happens instinctively and on a subsequent level, through your thoughts, feelings
and body language.
How does your attitude adds up? Each letter is assigned a number, for example A is the first letter in the
alphabet, so it’s equal to 1, B is the second letter, so it’s equal to 2 and so on. When you add up the number
for each letter in the word, it gets the total percentage of the word or text.
Coincidence or NOT?
If
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Equals
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Then
K N O W L E D G E
11 14 15 23 12 5 4 7 5 = 96
H A R D W O R K
8 1 18 4 23 15 18 11 = 98
Both are important, but fall just short of 100.
But
A T T I T U D E
1 20 20 9 20 21 4 5 = 100
Input: a non-empty text composed only of uppercase letters of the English alphabet. The length of the text
is less than 100. There are no any spaces in the input.
Output: output a single line containing the equivalent number or percentage of the text.
Example:
Enter a Text: KNOWLEDGE
Its equivalent percentage is 96
Enter a Text: HARDWORK
Its equivalent percentage is 98
Enter a Text: ATTITUDE
Its equivalent percentage is 100
Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
Problem Set #5 (40 pts)
Many internet protocols these days include the option of associating a media type with the content being
sent. The type is usually inferred from the file extension. You are to write a program that facilitates the lookup
of media types for a number of files.
You will be given a table of media type associations that associate a certain file extension with a certain
media type. You will then be given a number of file names, and tasked to determine the correct media
type for each file. A file extension is defined as the part of the file name after the final period. If a file name
has no periods, then it has no extension and the media type cannot be determined. If the file extension is
not present in the table, then the media type cannot be determined. In such cases you will print "unknown"
as the media type. If the file extension does appear in the table (case matters), then print the associated
media type.
Input: Input begins with 2 integers N and Q on a line. N is the number of media type associations, and Q is
the number of file names. Following this are N lines, each containing a file extension and a media type,
separated by a space. Finally, Q lines, each are containing the name of a file.
N and Q will be no greater than 100 each. File extensions will consist only of alphanumeric characters, will
have length at most 10, and will be distinct. Media types will have length at most 50, and will contain only
alphanumeric characters and punctuation. File names will consist only of alphanumeric characters and
periods and have length at most 50.
Output: For each of the Q file names, print on a line the media type of the file. If there is no matching entry,
print "unknown" (quotes for clarity).
Example
Enter Number of Media Type Association (N): 5
Enter Number of File Names (Q): 6
Media Type 1: html text/html
Media Type 2: htm text/html
Media Type 3: png image/png
Media Type 4: svg image/svg+xm
Media Type 5: txt text/plain
File Name 1: index.html
File Name 2: this.file.has.lots.of.dots.txt
File Name 3: nodotsatall
File Name 4: virus.exe
File Name 5: dont.let.the.png.fool.you
File Name 6: case.matters.TXT
File 1 is text/html
File 2 is text/plain
File 3 is unknown
File 4 is unknown
File 5 is unknown
File 6 is unknown
Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
Part 2. General Direction: Create a C# program that will compute for the total number of votes for each
candidate during the midterm election based on the specification stated below. Use minimum of 3
functions.
0 1 2 3 4
(Candidate) (Luzon) (Visayas) (Mindanao) (NCR)
0 Grace Poe 2654119 3092657 765098 1345091
1 Cynthia Villar 4983213 2983122 987540 3102992
2 Ronald Bato Dela Rosa 1247942 890938 2039651 360921
3 Benigno Bam Aquino III 900567 732123 297321 708921
4 Ramon Bong Revilla 109285 986540 1089268 1056782
5 Pia Cayetano 919089 816549 2803213 2098341
6 JV Ejercito Estrada 849321 742134 541345 1094848
7 Sonny Angara 109212 972122 1836131 4092131
String [ , ] candidate= {{“ Grace Poe”,”2654119”,”3092657”,”765098”,”1345091”},
{“Cynthia Villar”,”4983213”,”2983122”,”987540”,”3102992”},
{“Ronald Bato Dela Rosa”,”1247942”,”890938”,”2039651”,”360921”},
{“Benigno Bam Aquino III”,”900567”,”732123”,”297321”,”708921”},
{“Ramon Bong Revilla”,”109285”,”986540”,”1089268”,”1056782”},
{“Pia Cayetano”,”919089”,”816549”,’’2803213”,”2098341”},
{“JV Ejercito Estrada”,”849321”,”742134”, “541345”,”1094848”}
{“Sonny Angara”,”109212”,”972122”,’’1836131”,”4092131”}};
Given the String array candidate having the initialization shown on the table above get the following:
Name of the candidate who obtained the highest number of combined votes (10 points)
Name of the candidate who obtained the lowest number of combined votes (10 points)
Combined Votes = Luzon Votes + Visayas Votes + Mindanao Votes + NCR Votes
Name of the candidate who obtained the highest votes in Luzon (10 points)
Name of the candidate who obtained the highest votes in Visayas (10 points)
Name of the candidate who obtained the highest votes in Mindanao (10 points)
Name of the candidate who obtained the highest votes in NCR (10 points)
Names candidates with the top five (5) highest combined votes (15 points)
Names candidates who were not able to make it in the magic five (5) (15 points)
SAMPLE OUTPUT:
Candidate Name Total Number of Votes
Grace Poe 7856965
Cynthia Villar 12056867
Ronald Bato Dela Rosa 4539452
Benigno Bam Aquino III 2638932
Ramon Bong Revilla 3241875
Pia Cayetano 6637192
JV Ejercito Estrada 3227648
Sonny Angara 7009596
Candidate with the highest combined votes: Cynthia Villar
Candidate with the lowest combined votes: Benigno Bam Aquino III
Republic of the Philippines
Cagayan State University
CARIG CAMPUS
Carig Sur, Tuguegarao City
COLLEGE of INFORMATION and COMPUTING SCIENCES
Candidate with the highest votes in Luzon: Cynthia Villar
Candidate with the highest votes in Visayas: Grace Poe
Candidate with the highest votes in Mindanao: Pia Cayetano
Candidate with the highest votes in NCR: Sonny Angara
List of Top 5 Candidates:
Cynthia Villar
Grace Poe
Sonny Angara
Pia Cayetano
Ronald Bato Dela Rosa
List of Bottom 3 Candidates:
Ramon Bong Revilla
JV Ejercito Estrada
Benigno Bam Aquino III
Prepared by:
SHERWIN M. CAACBAY, MIT
Subject Instructor, ES 122