Академический Документы
Профессиональный Документы
Культура Документы
1.
Write a program that enters co-ordinates of three points A(x 0,y0), B(x1, y1), C(x2, y2),
checks if they are three valid vertex co-ordinates of a triangle
2. Write a program that enters a month, year, prints out number of days in the month
o It is known
o month 1,3,5,7,8,10,12
: number of days is 31
o month 4,6,9,11
: number of days is 30
o month 2
o leap year is
3.
4.
5.
6.
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
7. Write an algorithm to accept a number between 1 and 9 and display a pyramid. For
example, if the number entered is 5, the following pyramid will be displayed:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
8. Write a program to read an integer number (n>0). Write following methods:
- Checking whether a number is a perfect number or not?
- Generate the first n perfect numbers.
9. Write a method to enter a integer number (n>0) and reserve that number.
Guide: The reverse number is an integer number source from the orgine one but the
order of digits are reversed.
Example: The reverse number of:
12345 is 54321
2008 is 8002
1990 is 991
300400 is 4003
10. Write a method to check whether a valid number or not?
Guide: The valid number is a positive integer number which has 3 digits. Otherwise
is invalid number
Example:
123 is valid
23 -> invalid
4567 -> invalid
Input: an integer number from keyboard
Output:
If the input number is invalid (khng hp l), print out to console the
message: "N/A";
- If the input number is valid print out the reverse number of the input.
Example
Input:
01
Output:
N/A
--Input:
980
Output:
89
11. Write a program to find Highest Common Factor (HCF) and Least Common
Multiple of two integer numbers.
12. Write an algorithm to find the Highest Common Factor (HCF) of three numbers.
Input:
Three integer numbers from keyboard
Output:
Highest Common Factor (HCF) of three numbers.
Example
Input:
25
15
75
Output:
5
--Input
2
7
4
Output
1
13. Solve linear equation in one variable
bx + c = 0
Note: creat the following constructors:
public LinearEquation()
public LinearEquation(float b, float c)
14. Solve square equation in one variable
ax2 + bx + c = 0
public SquareEquation()
public SquareEquation(float a, float b, float c)