7
Exercise 02.02 - ABAP Basics Data Handling

2.2 ABAP Basics Data Handling 2

Embed Size (px)

Citation preview

Page 1: 2.2 ABAP Basics Data Handling 2

Exercise 02.02 - ABAP Basics Data Handling

Page 2: 2.2 ABAP Basics Data Handling 2

Exercise 02.02 ABAP Basics – Data Handling

Note: All the following objects to be created should follow the naming convention – YUSERID_##$$%%. ##$$ indicates the exercise number (02.02 for this assignment) and %% indicates the question number in the exercise. USERID indicates the network userid.

1. An Insurance company follows following rules to calculate premium.a. If a person’s health is excellent and the person is between 25 and 35 years

of age and lives in a city and is a male then the premium is Rs.4 per thousand and his policy amount cannot exceed Rs.2 lakhs.

b. If a person satisfies all the above conditions except that the sex is female then the premium is Rs.3 per thousand and her policy amount cannot exceed Rs.1 lakh.

c. If a person’s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then the premium is Rs.6 per thousand and his policy cannot exceed Rs.10, 000.

d. In all other cases the person is not insured.Write a program to output whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured. (Accept the required inputs)

2. A certain grade of steel is graded according to the following conditions:

a. Hardness must be greater than 50b. Carbon content must be less than 0.7c. Tensile strength must be greater than 5600

The grades are as follows:

Grade is 10 if all the three conditions are met.Grade is 9 if conditions (a) and (b) are met.Grade is 8 if conditions (b) and (c) are met.Grade is 7 if conditions (a) and (c) are met.Grade is 6 if only one condition is met.Grade is 5 if none of the conditions are met.

Write a program, which will require the user to give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.

- Page 2 of 5 -

Page 3: 2.2 ABAP Basics Data Handling 2

Exercise 02.02 ABAP Basics – Data Handling

3. Write a program that receives the month and year from the user as integers and prints the calendar in the following formats:

Format 1:

March 1995

Mon Tue Wed Thu Fri Sat Sun1 2 3 4 5

6 7 8 9 10 11 1213 14 15 16 17 18 1920 21 22 23 24 25 2627 28 29 30 31

Format 2:

March 1995

Mon 6 13 20 27Tue 7 14 21 28Wed 1 8 15 22 29Thu 2 9 16 23 30Fri 3 10 17 24 31Sat 4 11 18 25Sun 5 12 19 26

Note: According to the Gregorian calendar 01/01/1900 was Monday. With this as the base, the calendar should be generated.

4. Accept a number from the user to print the following output. For example, if the user enters 5, the output would be as follows. Write a program to obtain the following output:

XX XXXX XX

XX XX 5 linesXX XX

XX XX XX

XX XX XX XX

XX XX XX XX

XX XX

- Page 3 of 5 -

Page 4: 2.2 ABAP Basics Data Handling 2

Exercise 02.02 ABAP Basics – Data Handling5. Write a program to find out the factorial of a given number.

6. Write a program to find out whether the given string is a palindrome or not.

7. Accept a string from the user and for each character of the string, display the character that is immediately next to it in the alphabet and form another string. For example, if the user enters “HELLO”, then the output should be “IFMMP”.

8. Write a program to generate the following number series. The number of numbers to be displayed should be accepted from the user.10, 15, 20, 21, 31, 41, 43, 63, 83.

9. Write a program to accept a number ‘N’ from the user and display the first ‘N’ numbers of the fibonacci series.Fibonacci series: 1, 1, 2, 3, 5, 8, 13, 21, 34…

10. Accept 2 digits (positions) and an integer from the user and display the sum & product of the digits present in the user specified positions. (Without using offset option). For example, if the user enters 3, 5 and 394036187 respectively, the output should be 4 + 3 = 7 & 4 * 3 = 12.

11. Write a program to display the sum of the squares of first 25 odd numbers and sum of the squares of first 25 even numbers.

12. Accept a number from the user and display its roman equivalent. The following table shows the roman equivalent of the corresponding decimal numbers:

Decimal Roman1 I5 V10 X50 L100 C500 D1000 M

Example: 1988 – MDCCCCLXXXVIII

13. Write a program to accept a number from the user and print it out digit by digit as a series of words.For example: 1253 – One thousand two hundred and fifty three.

14. Write a program to accept a string and identify and print all the distinct characters in the string in the order of their appearance.

15. Write a program to accept a string from the user and display the following:

- Page 4 of 5 -

Page 5: 2.2 ABAP Basics Data Handling 2

Exercise 02.02 ABAP Basics – Data Handlinga. Distinct vowels b. Distinct consonantsc. Total number of vowels (all occurrences) d. Total number of consonants (all occurrences)

16. Write a program to simulate the functionality of STRLEN.

- Page 5 of 5 -