Common Computer Science References
A Boolean expressions is the heart of decision making and gives your program the ability to adapt when it needs to.
Below is a list of possible problems that MUST be solved using some kind of decision structure. You need to pick one that no one else in the class has selected and solve this problem for the assignment. Do not wait until the last minute.
If you are not sure on any part of the problem, just ask me and I will give you additional information.
I can get a bonus? Yes you can!
If you complete just the above part of the assignment in Python, you will be marked out of 3+. You will be marked out of 4+ if you do the programming in C as well.
Come up with your own question that uses a decision structure. Let me know what it is in advance and if I approve of it, you can then use it. 😊
Write a program to solve quadratic equations (use if, else if and else).
Take three numbers from the user and print the greatest number.
Write a program that reads in two floating-point numbers and tests whether they are the same up to three decimal places.
Write a program that asks the user to provide a single character from the alphabet and then prints "Vowel" or "Consonant", depending on the user input (print "sometimes" for y).
Take the values of length and width of a rectangle from the user and check if it is square or not.
A shop will give discounts of 10% if the cost of purchased quantity is more than 1000 units. Ask user for quantity. Suppose, one unit will cost $100. Determine and print total cost for user, including HST.
A company decided to give a bonus of 5% of their yearly salary to employees if their years of service is more than 5 years. Ask the user for their salary and year of service and print the net bonus amount.
A student will not be allowed to sit in the exam if their attendance is less than 75%. Take following input from the user:
Number of classes held
Number of classes attended
Then print the percentage of class attended. Is student is allowed to sit the exam or not?
Write a program to check whether an entered character is lowercase ( a to z ) or uppercase ( A to Z ), by using ASCII and not a huge if ... else if. (this might help: ord('a') will give 97!, in pyhton)
Write program to allow the user to input their age. Then the program will show if the person is eligible to vote. A person who is eligible to vote in Canada must be older than or equal to 18 years old.
Write a program that accepts 3 numbers. If all 3 numbers are between 0->100, find the average. If not, tell the user. You could not use a built in average function!
Write a program that accepts 2 numbers. Tell the users what number is larger and smaller. If both are equal, tell them that.
Write a program that accepts the weight of a package (kg) and the length, width and height (cm). Calculate the volume. The company will not accept packages 27 kg and larger than 10,000 cubic cm. Tell the user if the company will accept the package and if not why not.
When you go to the bakery, if you buy less than 6 of an item you pay HST. If you buy 6 or more of an item, you do not pay HST. Create a program that asks how many croissants you want (that cost $2.55) each and then calculates the total cost, with tax if there is any.
Write a program that accepts an integer. It then tells the user if it is even or odd. (the modulus operator might be helpful!)
Write a program to accept a coordinate point in a XY coordinate system, like (3,7), and determine in which quadrant the coordinate point lies in.
Write a program to check whether a triangle is Equilateral, Isosceles or Scalene.