Class XI 083 Lists and Strings practice programs.

Program 1: Write a program that reads a list of scores and then assign grades based on the following sheme:

The grade is A if score is >= highest - 10
The grade is B if score is >= highest - 20
The grade is C if score is >= highest - 30
The grade is D if score is >= highest - 40
The grade is F otherwise.

Sample Run: Enter scores: 40 55 70 58
Student 0 score is 40 and grade is C
Student 1 score is 55 and grade is B
Student 2 score is 70 and grade is A
Student 3 score is 58 and grade is B

Program 2: Write a program that reads some integers between 1 and 100 and counts the occurrences of each.

Sample Run: Enter integers between 1 and 100: 2 5 6 5 4 3 23 43 2
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occur 1 time
23 occurs 1 time
43 occurs 1 time

Program 3: Some websites impose certain rules for passwords. Write a function that checks whether a string is a valid password. Suppose the password rules are as follows:
1. A password must have at least eight characters.
2. A password must consist of only letters and digits.
3. A password must contain at least two digits.

Write a program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise.

Practice Assignment date: 19.07.14 12:05 pm
Submission date: 21.07.14 5:00 pm

No comments:

Post a Comment