Some of my java code assignment submitted as part of ICS3U7.
(aaray, for loop and while loop)
This program saved 1000 random numbers in an array and sort them in ascending order using Bubble Sort algorithm.
(do-while loop and if-else)
This program print Hailstone Sequene for an integer number entered. If the number is even it is divided in halg and if it is odd, it is multilpied by 3 and then add 1. This is repeated until the number reaches 1.
e.g. for number 3 entered by user, it will print 3 10 5 16 8 4 2 1
(for loop, while loop, if-else)
This program prints prime factor of any integer number entered by user, it will print following 2 lines - 3 to the power of 2 5 to the power of 1
e.g. for number 45 entered
(while loop, if)
This program prints each digit in reverse order of an integer number entered by user.
e.g. for number 483 entered by user, it will print 3 8 4
(use Scanner class)
This program prnts which digit is in one place or tens place or hunderds place for a 3 digit integer number entered by user.
e.g. for number 345 entered by user, it will print The hundreds-place digit is: 3 The tens-place digit is: 4 The ones-place digit is: 5
(while loop, it)
This program calculates the cube of each digit of 2 digit number and the prints ths sum.
e.g. for number 34 entered (3^3 + 4^3 = 27 + 64 = 91), it will print The sum of the cubes of the digit is 91
This programs genertes a random number and then multiply and add some static number. It then calculates time in 24 hour format hr:mm:ss. It also does some price calculations of a random number and then prints.
(while loop, if-else)
This program tries to match an entered 4 digit integer number with 1234. It allows user to retry maximum 3 times.
This is a sample for rounding a number to 2 digit decimal places.