You are on page 1of 5

COMP6047 – Algorithm and Programming (4/2)

1. Create a program to get 4 input (a, b, c, d).


Input
The first and second input is the first box weight, the first input is in kilogram and
the second input is in gram. (0 ≤ a ≤ 10, 0 ≤ b ≤ 999)
The third and fourth input is the second box weight, the third input is in kg and the
fourth input is in oz. (0 ≤ c ≤ 10, 0 ≤ d ≤ 999)
Output
The output is the difference weight of these two boxes.

1st Sample Input


3 800 2 600
Output for 1st Sample Input
1 200

2nd Sample Input


1 200 3 0
Output for 2nd Sample Input
1 800

2. Create a program to get 1 input (a).


Input
The input is integer. (0 ≤ a ≤ 20)
Output
The output is the series of numbers with this function:

( ) { ( ) ( ) ( )

1st Sample Input


2
Output for 1st Sample Input
012

1710 - FN
COMP6047 – Algorithm and Programming (4/2)

2nd Sample Input


5
Output for 2nd Sample Input
0, 1, 2, 2, 5, 12

3. Create a program to get 1 input (a).


Input
The input is one string that contain 3 words combination separated by ‘-‘. The first
word (x) is name (validate the word contain alphabeth, the length is between 5-15
characters). The second word (y) is secret code (validate the word contain alphabeth
and numeric, the length between 3-5 characters). The third word (z) is age (validate
age is an integer between 15-45)
Output
The output is the series of numbers with this function shown as sample below
1st Sample Input
TerRi-X2jK0-20
Output for 1st Sample Input
Hello Terri, you were born in 1997
Your new secret code is X2JK0

2nd Sample Input


paLMer-21iuyY-15
Output for 2nd Sample Input
Hello Palmer, you were born in 2002
Your new secret code is 21IUYY

4. Create a program to get n input.


Input
The first input is n number (2 ≤ n ≤ 10). Then ask user to input string n times

1710 - FN
COMP6047 – Algorithm and Programming (4/2)

Output
Sorted data and Modification status (all data has been sorted before -> no
modification, there are already sorted data in the right place -> small modification,
there are no sorted data -> big modification)
1st Sample Input
3
Alpha
Charlie
Beta
Output for 1st Sample Input
Alpha ; Beta ; Charlie
Small Modification

2nd Sample Input


3
Alpha
Beta
Charlie
Output for 2nd Sample Input
Alpha ; Beta ; Charlie
No Modification

3rd Sample Input


3
Charlie
Alpha
Beta
Output for 3rd Sample Input
Alpha ; Beta ; Charlie
Big Modification

1710 - FN
COMP6047 – Algorithm and Programming (4/2)

5. Create a program to get 2 input (a, b).


Input
The first input is the word (can be more than 1 word, validate the length is between
5-25 characters)
The second input is one word (validate that the alphabeth in the word is unique)
Output
The output of this program is total alphabeth from the second word in the first input.
1st Sample Input
Binus UnIverSity
aeiou
Output for 1st Sample Input
a: 0; e: 1; i: 3; o: 0; u: 2;

2nd Sample Input


HeLLo WorlD
hlw
Output for 2nd Sample Input
h: 1; l: 3; w: 1;

6. Create a program to get 3 input as much as n input and 1 input as the sort criteria.
Input
The first input is n (1 ≤ n ≤ 5)
The second input is name (validate the length is between 5-25 characters).
The third input is code (validate the length must be 5 characters alphanumeric).
The fourth input is stock (validate the stock is between 0-15).
Store the second until fourth input in one struct.
The last input is string (validate the input is ascending/descending).
Output
If the last input is ascending, show the data sorted by name ascending, else if the last
input is descending, show the data sorted by stock descending.

1710 - FN
COMP6047 – Algorithm and Programming (4/2)

1st Sample Input


3
Estella Giles;XI102;5
Karenza Sherilyn;19IA7;12
Bart Mason;9999X;7
ascending
Output for 1st Sample Input
Bart Mason;9999X;7
Estella Giles;XI102;5
Karenza Sherilyn;19IA7;12

2nd Sample Input


3
Estella Giles;XI102;5
Karenza Sherilyn;19IA7;12
Bart Mason;9999X;7
descending
Output for 2nd Sample Input
Karenza Sherilyn;19IA7;12
Bart Mason;9999X;7
Estella Giles;XI102;5

1710 - FN

You might also like