Skill set for this LAB:
print(format(1232.566777, '.2f'))
print(format(1232.566777, '.4f'))
print(format(variable_name, '.2f')) will print variable_name with only 2 decimal digits after decimal point
Problem 1 Write a program that finds the maximal and minimal values among four integeres.
Problem 2
The McDowell Restaurant chain has asked you to write a menu program for
their new Fast-food service machines. Your program should print a menu
like this:
McDowell.s Restaurant
Make your selection from the menu below:
1. Regular Hamburger $1.50
2. Regular Cheeseburger $1.75
3. Fish Sandwich $2.50
4. Half-pounder with cheese $2.75
5. French Fries
$0.99
6. Large Soft Drink $1.25
Select 1, 2, 3, 4, 5, or 6 ----- >
Write a program that reads customer's selection and computes the price, including 7% sales tax. Note that using this menu, the customer can make just one selection. The input is one number, and the output is the price to pay or the error message "invalid choice".
Problem 3 In the Gregorian calendar a year is a leap year when the number representing it is divisible by 4, unless it is divisible by 100, unless it is divisible by 400. Thus years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years. Also, you can assume that there were no leap years before 1582. Write a program that asks the user for a year and computes whether that year is a leap year. You can assume that the input is a valid positive integer less than 4000. You don.t need to check validity of the input.
Example:
Input 1980 Output Leap Year
Input 1900 Output Not a Leap Year
Input 1200 Output Not a Leap Year
Input 2000 Output Leap Year
Input 3000 Output Not a Leap Year
Problem 4 Write a program that prompts the user to enter three integer numbers. For each number, the program determine whether the input number is greater than 5, less than 5 or equals 5. The program should print an appropriate message for each case. For example, if the input is 3, the output should be: 3 is less than 5; if the input is 106, the output should be: 106 is greater than 5; and if the input is 5 , the output should be: 5 equals 5.
Problem 5 Write a program that prompts the user to enter one positive 4 digits integer. The program will do the following: if the input number is even, the program will print the digits of the number in the reverse order, and if the input number is odd, the program will calculate the sum and the product of the digits and prints the result with the appropriate message. Hint: An even number is an integer that is "evenly divisible" by 2, i.e., divisible by 2 without remainder i.e., remainder = 0
Problem 6
Write a program that
prompts the user
to enter three integers, reads input numbers into variables num1, num2,
and num3
of type int.
The program will sort the input numbers and print the input numbers in
the increasing order. You can assume that the input numbers are different.
For example if the input was 4, -9 and 8 the program should output:
-9, 4, 8
For example , if the input was 1, 0, -90 the program should output:
-90, 0, 1
Try to find a most efficient solution.
Problem 7 There is a treasure chest with 1 million dollars. The chest has a 5-digit combination lock that opens under the following conditions: the first digit should be equal to the fifth digit, the second digit should be odd, and the product of the third and forth digits should be divisible by 7. Write a program that reads one 5-digit positive integer and checks whether the input number opens the chest or not. The output should be YES, if the chest opens, and NO otherwise.
Problem 8 A company wants to transmit data over the telephone line, but they are concerned that their lines are tapped. All of their data is transmitted as four-digit integers. They decided to encrypt a four-digit number as follows: (1) they will replace each digit by ((digit + 7) mod 10); (2) they will then swap the first digit with the third digit and the second digit with the fourth. The resulting four-digit number is the encrypted number. To decrypt the number, the reverse procedure should be applied (you need to figure out the algorithm). Write a program that can do either encryption or decryption. The program must take two inputs. The first input must be either 1 or 2, with 1 signaling encryption and 2 signaling decryption. The second input is a positive integer less than 10,000 which will be either encrypted or decrypted depending on the first input.