Institute of Computer Science
  1. Courses
  2. 2020/21 fall
  3. Introduction to Programming (MTAT.03.236)
ET
Log in

Introduction to Programming 2020/21 fall

  • Home
  • Grading
  • Links

Homework 5

The deadline is Sunday, the 11th of October, 23:59 (Estonian time).

Exercise 1. Name and grades

Write a program that asks the user for his first name and grades. Regardless of how the user enters the name and grades (in lower and capital letters or mixed), the output of the program has to be formatted so that the name begins with the capital letter followed by lower case letters, and all the grades are in the upper case. On the next line, the program has to show the number of the grades. Next, the grade for the second course has to be shown (assume that the number of the entered grades is at least 2). On the last line, the program has to show the number of A's and B's (counted together).

Here is an example of the program output:

 Enter first name: mAriNa
 Enter grades: aaAbBcDaD
 Hello Marina, your grades are AAABBCDAD
 You have 9 grades
 Your grade for the second course is A
 The number of A's and B's is 6

Hint: Look at string functions from string library.

Exercise 2. Username from url

Every user of the University of Tartu (a student or a member of staff) has his/her home directory in the Study Information System. The user can create a webpage on the university server. The url for his/her webpage is www.ut.ee/~username/ (e.g. www.ut.ee/~vilo/). Write a program that prompts the user for a university url. The program then has to look for the user name and print it out.

Here is an example of the program output:

 Please enter url: http://www.ut.ee/~koit/KT/index_eng.html
 Username is koit

Go to Moodle and upload your solution into Homework 5.

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment