Pseudo code:
Question 3:
Code:
1. Declare amount
2. Print “Enter total amount: “
3. Input amount
4. If (amount >= 500)
4.1. Print “You can withdraw amount”
Otherwise
4.1. Print “You cannot withdraw amount”
Question 5:
Code:
1. Declare age, drivingCourse, visionTest
2. Print “Enter your age: “
3. Input age
4. Print “Enter if you have done a driver’s course yes/no: ”
5. Input drivingCourse
6. Print “Enter if you have passed vision test yes/no: ”
7. Input visionTest
8. If ((age >= 16) AND (drivingCourse == “yes”) AND (visionTest == “yes”))
8.1. Print “You are eligible for license”
Otherwise
` 8.1. Print “You are not eligible for license”
Question 6:
Code:
1. Declare age, vaccinations
2. Print “Enter your age: ”
3. Input age
4. Print “Enter if you have done all vaccinations yes/no: ”
5. Input vaccinations
6. If ((age > 65) OR (age < 18) OR (vaccinations == “no”))
6.1. Print “High risk for international travel”
Otherwise
6.1. Print “Eligible for international travel”
Question 7:
Code:
1. Declare english, math, science
2. Print “Enter your marks in english: ”
3. Input english
4. Print “Enter your marks in mathematics: ”
5. Input math
6. Print “Enter your marks in science: ”
7. Input science
8. If ((english >= 50) AND (math >= 50) AND (science >= 40))
8.1. Print “You have passed the exams.”
Otherwise
8.1. Print “You have not passed the exams.”
Question 8:
Code:
1. Declare age
2. Print “Enter your age: ”
3. Input age
4. If ((age >= 18) AND (age <= 75))
4.1. Print “You are eligible for driving license.”
Otherwise
4.1. Print “You are eligible for driving license.”
Question 9:
Code:
1. Declare num
2. Print “Enter a number:”
3. Input num
4. If (num >= 0)
4.1. Print num
Otherwise
4.1. Print num*(-1)
Question 10:
Code:
1. Declare marks
2. Print “Enter marks:”
3. Input marks
4. If (marks >= 80)
4.1. Print “Good luck”
Otherwise
4.1. Print “Better luck next time.”
Question 11:
Code:
1. Declare num1, num2
2. Print “Enter a number:”
3. Input num1
4. Print “Enter a number:”
5. Input num1
6. If (num1 % num2 == 0)
6.1. Print num1, “is divisible by”, num2
Otherwise
6.1. Print num1, “is not divisible by”, num2
Question 12:
Code:
1. Declare hrsWork, ratePerHour, regPay, overtime
2. Print “Enter Employee total hours worked: ”
3. Input hrsWork
4. Print “Enter Employee hourly pay rate: ”
5. Input ratePerHour
6. If (hrsWork < 40)
6.1. regPay = hrsWork * ratePerHour
6.1. Print “Regular pay: ”, regPay
6.2. Print “Total pay:”, regPay
Otherwise
6.1. regPay = 40* ratePerHour
6.2. overtime = (hrsWork – 40) * 1.5 * ratePerHour
6.1. Print “Regular pay: ”, regPay
6.2. Print “Overtime pay: ”, overtime
6.3. Print ”Total pay: ”, regPay + overtime
Question 13:
Code:
1. Declare num, num1, num2, num3, num4
2. Print “Enter a 4-digit number: ”
3. Input num
4. num4 = num % 10
5. num = num / 10
6. num3 = num % 10
7. num = num / 10
8. num2 = num % 10
9. num = num / 10
10. num1 = num % 10
11. print num1, "-", num2, "-", num3, "-", num4
Question 14:
Code:
1. Declare num, firstDigit, lastDigit
2. Print “Enter a three digit number:”
3. Input num
4. firstDigit = num % 10
5. lastDigit = num / 100
6. If (firstDigit == lastDigit)
6.1. Print num, “is palindrome.”
Otherwise
6.1. Print num, “is not a palindrome.”