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 Practice Java Evaluation 5

IB Computer Science Question 1

Consider the following game that used to be played on TV. Its called “Deal or no Deal”. You might want to look up a video on YouTube of it being played.

To keep things simple, in our version, there are 10 possible dollar amounts. $100, $500, $1000, $5000, $10000, $25000, $50000, $100000, $500000, $1000000 sealed in imaginary briefcases which we will number from 1 to 10.
• 1 -> $100
• 2 -> $500
• Etc….

Your task is going to be to help the contestant decide if they should take the deal or not take the deal that is presented by the banker at a given point in the game. You will make this decision based on the average of the remaining unopened briefcases and comparing that value to the Bankers offer. If the offer is higher than that average remaining the player should take the deal, otherwise the player should not take the deal.

The input for this game will be as follows:
• The first number will be how many cases have already been opened
• The next several numbers will be the case #’s of the opened cases. (How many will depend on what the first number was)
• The last number will be the bankers offer.

For Example:
If the first number entered was 3, then the program would then ask for the case numbers of the 3 cases that have already been opened. If the user enters, 1, 3, 10 then the $100, $1000, $1000000 cases are not available prizes anymore leaving an average value of the remaining cases
Average Remaining = (500 + 5000 + 10000 + 25000 + 50000 + 100000 + 500000) / 7 = 98642.86

If the last number entered was 75000, then the player should not take the deal.

Your program will output the average and the recommendation.

IB Computer Science Question 2

Consider the following definitions:
Plaintext: A message that can be read in normal English
Ciphertext: An encoded (scrambled) message that needs to be decoded (unscrambled) to plaintext

A simple substitution cipher algorithm is one that each character in the plaintext is “shifted” a certain number of places down the alphabet.

For example, if the shift is 2
• A becomes a C
• F becomes H
• Z becomes B

Here is a full example using a shift of 1

IB Computer Science Cipher

If you want to decode the ciphertext message into plaintext, you need to know the shift value. One way to accomplish this is to decode the message with all 26 possible shift values and see what plaintext result is readable in English. This is not overly efficient but works as a brute force decoding algorithm.

To keep things interesting in this question, let’s use the fact that because the letter ‘e’ is the most commonly used letter in the English alphabet (13%), whatever letter appears the most often in the ciphertext will represent the letter ‘e’ in the plaintext message. You can use that information to deduce what the shift value is.

Your task is to write a program that can take a ciphertext message and decode it to plaintext.  Make sure your solution finds a way to incorporate methods.  In addition to your java solution, please hand in a screen shot or photo of some ciphertext examples you used to test your program.

IB Computer Science Question 3

In Mathematics, the STANDARD DEVIATION is a measurement of how spread out a list of numbers is.
The standard deviation of a list is calculated as follows

IB Computer Science Java Standard Deviation

In most normal situations you would expect most of the data to fall within one standard deviation of the average.

For example, if a class has an average of 75 and the standard deviation is 15, then that indicates that any student who has an average above 90 (75+15) or below 60 (75-15) is somehow exceptional compared to the rest of the class.

Write a program that
1. Asks the user for two numbers:
• The amount of numbers in a list
• A number to check if its exceptional.

2. Displays the standard deviation of a random list of numbers between 0 and 100

3. Displays if the number entered was exceptional for that list

Write the following methods to assist you with the task
• Generates a list of N random integer numbers between 0 and 100 and stores them in an array
• Calculates the standard deviation and returns its value
• Checks if a number is considered exceptional or not and returns a true or false indicator

 

IB Computer Science Question 4

Create a Monogram application that prompts a user for
• First Name
• Middle Name
• Last Name

The program should then display two things
• The monogram of their name
• The monogram of their reversed name

(A monogram displays the first initial in lower case, then the last initial in upper case, then the middle initial in lowercase)

For Example if you entered my name
• Paul Brian Rogers
Your program would display
• pRb and sLn

Write two methods to accomplish the task
• A method that accepts any 3 word string and returns the monogram
• A method that reverses the letters in a string and returns the new String

NOTE: YOU CANNOT USE ANY OTHER WAYS TO CREATE STRINGS THAN THOSE OUTLINED IN THE NOTES.

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