IB Computer Science Unit 1
IB Computer Science Unit 2
IB Computer Science Unit 3
IB Computer Science Unit 4
IB Computer Science Unit 5
IB Computer Science Unit 6

IB Computer Science Problem Solving Part 2

IB Computer Science Learning Goals

In this IB Computer Science lesson you will be learning about:

  • Use Simple Math to Solve Problems
  • Think Sequentially about how a computer executes code
  • Use the Input  Processing Output Method of Problem Solving

Input - Processing - Output

It is a lot easier to write programs when you take a few minutes and think of the process that needs to occur in order for you to write your code. It is also important to know when you have finished your code if it is working properly.

  • In the last lesson you were introduced to the input – processing – output method of problem solving using pseudocode.
  • The curriculum requires you to formalize this and demonstrate to me that you are following this procedure when writing your programs.

In this lesson I’m going to give you an exemplar on how you should be submitting your programming assignments so that they will meet the curriculum expectations

Example – Suppose I give you a question that says the following:

Write a program that asks the user for 3 sides of a triangle and then calculates all the interior angles of that triangle to 1 decimal spot

Your solution will have 3 parts to it:

Part #1 – The Problem Solving

  • Here is where you will following the IPO method and plan out your program.
  • This is done BEFORE you write the code!!!!
  • It doesn’t have to be super detailed, but enough information should be given so that you could give it to any programmer and they could use it to write the code.
  • Input
    • Accept 3 whole numbers from the user (store as integer values)
    • Each one will be one side of the triangle
    • Not going to worry if the sides actually DO form a triangle, let’s just assume the user will enter the proper values as input
    • Processing
      • Here is the Math I’m going to need to use to calculate the interior angles
      • I will need 3 variables (doubles) to store the 3 angles
        • My program will likely have the following flow
          • Set the BufferedReader Variables for input
          • Declare input and output variables
          • Get the input from the user using readLine Statements
          • Apply the formula 3 times changing the sides used for a,b,c each time.
    • Output
      • The values need to be to 1 decimal spot so I will need to apply that in my print statements
      • Choose to output 1 angle per line.

 

IB-Computer-Science-More-Problem-Solving (1)

Part #2 – The Code

  • After you have finished your planning, go to Netbeans and use your plan to write the code.
  • If your original processing needs adjustment because there was something you didn’t think of then just do it.
    • Don’t go back and change your problem solving document.

Here is the code I would have written to solve answer the question.

IB-Computer-Science-More-Problem-Solving (2)

Part #3 – The Evaluation

  • Once your code is written you need to verify that you have completed the task as required.
  • To prove to me that you have done this I will require 2 Test Cases that show that your output is actually correct.
  • In this example that would be accomplished by pretending you were in Math Class and had to do this question on a test.

IB Computer Science Practice Questions

Complete the process outlined in the notes for each of these problems

  • Problem Solving
  • Java Solution
  • Evaluation

1. Create a program that asks the user to enter the amount they pay each month for:

  • Food
  • Clothing
  • Entertainment
  • Rent

Your program should then output the percentage of the total they spend on each of those 4 categories. Display the results to the nearest whole percentage and make sure the sum of the percentages is 100%


2. A fast food restaurant charges $2.49 for burgers, $1.89 for fries, and $0.99 for soft drinks.
Create an order form for a restaurant that helps employees take orders.

  • The user needs to be able to input the number of burgers, fries, and soft drinks
  • The program should display the total cost including HST
  • The user should be able to enter how much money was given to pay
  • The program should output how much change is needed

Looking to Learn More about Computer Science and Coding?

Check out our programing in python courses that focus on high school level coding.  

  • Grade 11 Computer Science ICS3U
  • Grade 12 Computer Science ICS4U

These courses are complete with interactive coding lessons, teacher led videos, and more practice questions with complete solutions

Return To International Baccalaureate Computer Science Main Page