Time
Ask the user for a number of minutes. Tell
them how many hours and minutes that is in time format (ex: 183 minutes
= 3:03)
Car
Ask the user for car model numbers. If the
number is 119, 179, 189-195, 221, or 780 tell them the car is defective
and needs to be brought in for repairs. Otherwise tell them the
car is OK. If they enter 0 the program should exit.
Sum of Digits
Ask the user for an integer, tell them what the sum
of the digits of the number is.
Bank Account
Ask the user for an initial deposit, an interest
rate, and a desired balance. Tell them how many years it would
take to reach their desired balance using that interest rate,
compounded anually.
Hailstone
Ask the user for a number to start with.
Create a sequence where
each new number in the sequence depends on the last one. If the
last
one was even, divide it by 2 to get the next one. If the last one
was
odd, multiply it by 3 and then add 1 to get the next one. If you
were
to continue this forever, eventually the numbers 4, 2, and 1 would
repeat forever. The sequence should end with 4, 2, and 1.
Also, say
how many steps it took to complete the sequence.
Ex: 23
23,70,35,106,53,160,80,40,20,10,5,16,8,4,2,1,...
15 steps
Necklace
Ask the user for two one-digit numbers. Create
a sequence where each new number in the sequence is the ones digit of
the sum of the last two numbers in the sequence. The sequence
ends when the first two digits are repeated. Also, say how many
steps it took to complete the sequence. Ex: numbers 1 and 8
1 8 9 7 6 3 9 2 1 3 4 7 1 8
12 steps
Necklaces
Perform the necklace problem for every possible set
of starting one-digit numbers.
Sum of numbers in a range
Ask the user for two numbers, then print out the sum
of all of the numbers between the two given (inclusive).
Sum of even numbers in a range
Ask the user for two numbers, then print out the sum
of all of the even numbers between the two given (inclusive).
Pass/Fail
Ask the user how many grades they want to
enter. Then, ask for each grade one at a time. Don't count
grades given that are not in the range of 0 to 100 (inclusive).
At the end, print out how many were passing grades ( >= 60% ) and
how many were failing ( < 59% ).
Factorial
Ask the user for a non-negative integer. If
they give a negative number, tell them that the factorial of a negative
number cannot be computed, and ask again for a number. Once a
valid number is obtained, the factorial should be calculated and
printed. The factorial of 0 is 1. For a positive integer,
it is the product of all of the numbers between one and the
number (inclusive).
Prime loop
Ask the user for numbers (until they enter
zero), telling them whether each number is prime or not.
Primes in a range
Ask the user for two numbers, and print out every
number between the two given (inclusive) that is prime.
Prime factors
Ask the user for numbers, printing out all of the
prime factors of each number (or "no prime factors") until the user
enters zero.
Hint, this is what the code should do:
Initialize a counter at 2
As long as the counter is less than or equal to half of the number...
If the counter divides evenly into the number, print out the counter
and divide the number by the counter to get a new number
Otherwise, increment the counter
Stars
Ask the user for a number, and print out the
following 4 patterns (the number determining the height and width of
each). Ex: 3
*
**
***
***
**
*
*
**
***
***
**
*