Uncategorized
Home > Uncategorized (Page 32)
Posted at 18:24h
in
Uncategorized
by admin
Question:
Continue modify the program we made in the class:
create Energy class. A new energy crystal object will be created when the enemy spaceship explode
use spritecollide to let the fighter collect energy crystals, if the energy crystal is collected, the score will increase
...
Posted at 18:17h
in
Uncategorized
by admin
Question:
Suppose we have a number like 12. Let’s define shifting a number to mean adding a zero at the end. For example, if we shift that number once, we get the number 120. If we shift the number again we get the number 1200. We...
Posted at 18:16h
in
Uncategorized
by admin
Question:
A palindrome is a word which is the same when read forwards as it is when read backwards. For example, mom and anna are two palindromes.
A word which has just one letter, such as a, is also a palindrome.
Given a word, what is the longest palindrome that is contained in...
Posted at 18:04h
in
Uncategorized
by admin
Question 1:The hailstone sequence starting at a positive integer n is generated by following two simple rules. If n is even, the next number in the sequence is n/2. If n is odd, the next number in the sequence is 3*n+1. Repeating this process, we generate the hailstone sequence. Write a recursive function hailstone(n) which prints the...
Posted at 15:11h
in
Uncategorized
by admin
Question 1.
Write a program to print a multiplication table (a times table). At the start, it should ask the user which table to print. The output should look something like this:
Sample Input:
Which multiplication table would you like? 5
Sample Output:
Here’s your table:
5 x 1 = 5
5 x 2...
Posted at 02:07h
in
Uncategorized
by admin
Question:
Anna and Jack are playing a game.
Each player starts with 100 points. The game uses standard six-sided dice and is played in rounds. During one round, each player rolls one die. The player with the lower roll loses the number of points shown on the higher...
Posted at 01:58h
in
Uncategorized
by admin
Question 1:
Write code to find the number of times a certain character appears in the string. Below is the sample execution of the code.
E.g. inside the string apple, the character p appears 2 times.
Question 2:
Create a Dog class just like we designed the pencil and...
Posted at 19:36h
in
Uncategorized
by admin
Question:Continue to program the code so the back(<-) button can work:
when you click the back button, it will delete the last digit or decimal. However if there’s only one digit left and that digit is not 0, it will change into 0. check the calculator...
Posted at 19:31h
in
Uncategorized
by admin
Question(Use Stack to solve the following question):
You are given a binary string, (string which contains 0's and 1's), You have to perform several operations on this string, in one operation choose a non-empty even length substring containing only 0's or only 1's and remove it from the...
Posted at 15:26h
in
Uncategorized
by admin
Question:
Modify the program we made in the class. Add starting screen as below, the real game will start when play click the mouse in the range of the “PLAY” button. (Scroll down for more hint)
You can download the background images from below:
The size of the...