Common Computer Science References
Yes you did, but now you know all the standard decision making structures AND you know how to ensure your program does not crash, no matter what the user enters.
Below is a list of possible problems that MUST be solved using some kind of decision structure. You need to pick one AND IT MUST NOT BE one that you picked last time, that no one else in the class has selected and solve this problem for the assignment. Do not wait until the last minute. This time your program IS NOT ALLOWED TO CRASH, no matter what the user enters as input.
If you are not sure on any part of the problem, just ask me and I will give you additional information.
Ensure your test case actually test for invalid input
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 gets a number from the user and displays the name of the weekday.
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 where you enter the month and it tells you the number of days in a month (bonus points for leap years!).
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 python)
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.
Write a program that you enter the number of sides and it returns what kind of polygon it is:
3 = triangle
4 = quadrilateral
...