Page 176, Questions 5.26 and 5.27
You must utilize the following two methods in your code to receive credit. If you do not use these methods you will not receive credite for 5.26 and 5.27:
int reverse(int n)
boolean isPrime(int n)
Distance Between Points
Write a method
distanceto calculate the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type
double. Incorporate this method into an application that enables the user to enter the coordinates of the points.
Table of Binary, Octal and Hexadecimal Numbers
Write a program that displays a table of the binary, octal, and hexadecimal equivalents of the decimal numbers in the range 1 through 256. The table should consist of 4 columns: Decimal, Binary, Octal, and Hex. Be sure all numbers are aligned in each column.
(1.5%) - Emirps
(1.5%) - Palindromic Primes
(1.5%) - Distance Between Points
(2.3%) - Table
November 23, 2009 - 11:40am
In this assignment you are to complete the following three (3) individual programs:
The factorial n! is defined for a positive integer n as:
n! = n x (n - 1) x ... 2 x 1
5! = 5 x 4 x 3 x 2 x 1 = 120
There is a special case, n = 0, in which:
0! = 1
Write a program that prompts a user for a value of n and then reports n!.
Greatest Common Divisor
The greatest common divisor of two numbers a and b is denoted GCD(a,b), and defined as the largest divisor common to both a and b. For example, GCD(3,6) = 3, GCD(25, 30) = 5, and GCD(7, 9) = 1. Write a program that prompts a user for a and b, and reports GCD(a,b).
A prime number p can be defined as a positive integer that is not divisible by any positive integers other than one (1) and itself (p). If a number p has positive divisors other than the numbers one (1) and p, it is said to be composite. Write a program that prompts the user for a value p, and then reports whether p is prime or composite.
(0.1%) Prompt user for n
(1.5%pts) Calculate and display the correct value of n!
(0.1pts) Display correct value for special case (n=0)
(0.1%) Prompt the user for a and b
(1.5%pts) Display the correct value of GCD(a,b)
(0.1%) Prompt the user for p
(2%) Correctly display whether p is prime or composite
November 2, 2009 - 11:40am
In this assignment you are to write the following programs:
Write a program that prompts the user to enter an integer within the range of ASCII values for an uppercase character. Your program should then output the corresponding ASCII character in both uppercase and lowercase. You can assume that the user will always enter in an ASCII code within the appropriate range. Use the console for all input and output.
Write a program that prompts the user for a monetary value and outputs the minimum number of coins needed to make the specified amount. For example, a user can enter 1.43 which corresponds to the monetary amount $1.43. Your program should then proceed to output the following:
Total Coins: 10
Use the JOptionPane for all input and output.
Write a program that prompts the user for a 4-digit integer, and then displays the number in reverse. You should not use any String functions to perform the reverse. Use the console for all input and output.
October 16, 2009 - 10:30am
In this assignment you are to setup a Java Development Environment on your own personal PC or Mac. Follow the directions here to download, install, and setup your development environment.
Once your development environment is setup, write a program that displays the following questions and their corresponding answers:
Q1. (1pt) What is the command to compile a Java program?
Q2. (2pts) What is the command to run a Java program?
Q3. (1pt) What is the file extension of a Java source file?
Q4. (1pt) What is the file extension of a compiled Java program?
Q5. (5pts) What is the binary representation of the decimal number 115?
Q6. (5pts) What is the hexadecimal representation of the binary number 10010011?
Q7. (5pts) Wrtie the Java code needed to display the text "Hello, World!" in a message dialog box.
Q8. (15pts) Define machine language, assembly language, and high-level programming language.
Q9. (10pts) What is a source program? What is a compiler?
Q10. (5pts) What is the JVM?
Upload your Java source code to the CSNS system before the due date and time. No late submissions will be submitted no matter how close to the due date/time. No exceptions!
October 2, 2009 - 10:30am
CSNS All files must be submitted to CSNS prior to the due date/time.