Quiz Date: Tue, Apr 1, 2003
Part 1: Written Portion
Question 1: Write a Java program which reads in an integer N, and prints out whether or not N is odd.
Question 2: Write a Java program which reads in an integer N, and prints out whether or not N is prime.
Question 3: Write a Java program which repeatedly reads in a positive integer n (quitting when n <= 0), and prints out n factorial, where n! = n * (n-1) * (n-2) * ... * 1. Thus, 3 factorial, written 3! = 3 * 2 * 1 = 6. And 4 factorial, written 4! = 4 * 3 * 2 * 1 = 24.
Question 4: Write a Java program which reads in integers, stopping only when the same integer is entered in twice in a row. Print out the total number of integers read.
Part 2: JCreator Portion
Question 5: Write a Java program which reads in an integer n and prints out the prime factorization of n. That is, the product of prime numbers which equals n. For example, if you read in 45, your program should print out 45 = 3*3*5. Be sure to get the asterisks right.
Question 6: Write a Java program which finds the single-digit numbers a, b, c, and d such that abcd = abcd. So, for example, the answer is not 4253, because 4253 = 16 * 125 = 2000 != 4253. Output the 4-digit number abcd. Note that your program must compute the answer, and not just print it out directly.
See Course Home Page.