$30
HomeWork-2
You must write name header on the top of every
homework assignment. (It will include your name, id, Assignment number).
Note: In all these exercises, pay attention on documentation. User has no idea about your code
and your algorithm. Keep our output “user friendly” so that user can understand what s/he is doing.
Exercise 1: (String Reading)
Write a program that reads 3 different strings from the keyboard (one word per line). Display the
strings (one per line) in lexicographic order (Number comes first, then uppercase, then
lowercase)
Test cases:
Hi hello
Hiya Hi
cool Cool
Bye Hi
Below is a sample transaction: (show your
output anyway you like)
Enter 2 strings (in any order):
Hi
Bye
In lexicographic ordering, the strings you
entered are:
Bye
Hi
Exercise 2: (Loan qualifier)
Bank policy decides whom to give the loan or not. ABC bank has a loan policy, person’s
minimum annual salary must be equal to 30,000 or more and number of years employed must be
equal to 2 or more. If either case is not fulfill, s/he won’t be qualified for the loan.
Write your code and must display the output by telling the user, why s/he didn’t qualify
for the loan (its salary or work experience). If the user qualifies for the loan, Congrats him/her!
Exercise 3: (Color mixer)
The color red, blue, yellow are known as the primary colors because they cannot be made by
mixing other colors. When you mix two primary colors, you get a secondary color, as shown
here.
Red + Blue = Purple
Red + Yellow = Orange
Blue + Yellow = Green
Design a program that prompts the user to enter the names of the two primary colors to mix. If
the user enters anything other than “red”, “blue”, or “yellow”, the program should display an
error message. Otherwise, the program should display the name of the secondary color that
results.
User must enter the name of the color in lowercase.
Must check the validity of both colors (means, they are primary colors or not) before
mixing them.
Must check, both colors are not same.
Exercise 4: (Time Calculator)
Write a program that ask the user to enter a number of seconds and works as follows:
There are 60 seconds in a minute. If the number of seconds entered by the user is greater
than or equal to 60, the program should convert the number of seconds to minutes and
seconds.
There are 3,600 seconds in an hour. If the number of seconds entered by the user is
greater than or equal to 3,600, the program should convert the number of seconds to
hours, minutes, and seconds.
There are 86,400 seconds in a day. If the number of seconds entered by the user is greater
than or equal 86,400, the program should convert the number of seconds to days, hours,
minutes, and seconds.
Exercise 5: (Hotdog cookout Calculator)
Assume hot dogs come in a packages of 10, and hot dog buns come in packages of 8. Write a
program that calculates the number of packages of hot dogs and the number of packages of
hotdog buns needed for a cookout, with a minimum amount of leftovers. The program should ask
the user for the number of people attending the cookout and the number of hot dogs each person
will be given. The program should display the following details.
The minimum number of packages of hot dogs required.
The minimum number of packages of hot dog buns required.
The number of hot dogs that will be left over.
The number of hot dog buns that will be left over.
Exercise 6: (Graphic-1)
Draw dots like the picture shown here. Start with the dot, move 100 pixel forward then Pen Up
and move 50 pixels. After the gap, start another picture with dot. Here we have total 3 pictures.
Pen size should be 10.
Pen color, I picked red. Feel free to pick your favorite color.
Move the turtle’s current position 100 pixels left
Exercise 7: (Graphic-2)
Draw a circle with radius 100 pixels.
Use the pen size 5 pixels.
Write “My Circle!” inside the circle, make sure it should look in the middle of the circle.
Fill the circle with any color. I have filled it with cyan color.