0% found this document useful (0 votes)
13 views

Java Assignment 1 Basic-New

The document provides 14 Java programming assignments involving variables, conditionals, loops, functions, and other basic Java concepts. The assignments include swapping variable values, calculating averages and ranks, solving linear equations, finding factorials and Fibonacci numbers, managing student data, determining number of days in a month, finding greatest common divisors, printing multiplication tables, and printing various patterns using loops and nested loops.

Uploaded by

datmtpd10529
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Java Assignment 1 Basic-New

The document provides 14 Java programming assignments involving variables, conditionals, loops, functions, and other basic Java concepts. The assignments include swapping variable values, calculating averages and ranks, solving linear equations, finding factorials and Fibonacci numbers, managing student data, determining number of days in a month, finding greatest common divisors, printing multiplication tables, and printing various patterns using loops and nested loops.

Uploaded by

datmtpd10529
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Assignment

JAVA ASSIGNMENT -1

1. Create two integer variables (a and b) after that assign value for them. Then swap
value of a and b.
Hint: Using a c variable to transfer value temporary.

2. Write a program to input three numbers as math, physics, and chemistry. Output
average and rank according to the following:

AVG Rank

>=8.0 A

>=6.5 B

>=5.0 C

<5.0 D

Hint: Declare average and rank variable and calculate value for them.

3. Write a program to find x from ax + b =0 equation with a and b are input from
keyboards.

4. Write a program to find x from ax2 + bx + c =0 equation with a and b are input from
keyboards.

5. Write a program to calculate sum of first 50 integer number.

6. Write a program accepts an integer number (n) from user the calculate n!(factorial of
n) then display the result to the screen.

7. Write a program to print to screen first 20 numbers of Fibonacci numbers.

8. Create an application to manage student’s information as below:


- Create variables to save a student’s information like: studentCode, studentName,
studentAge, studentSex and set value for them.
- Print student’s information to screen.
- Edit program to permit user inputs data from keyboard.

1
Professional Programmer Training Center
- Edit program to permit user inputs a list of student from keyboard until “n” key
pressed.

9. Write a program to accepts a number n from 1 to 12 and then print


number of days in month n of the current year. If user enter a number
out of range an error message will display.
Hint: Use switch case statement

10. Write program to accepts two integer numbers (a and b), then calculate
and display their greatest common divisor.
Hint: define function int greatestCommonDivisor(int a, int b)
Example: greatestCommonDivisor (18, 12) = 6;
(Ước số chung lớn nhất – Có thể xem thuật toán trên mạng)

11. Write a program print multiplication table.

12. Write a program to accept an integer number and print the rectangle as
below: (use loop statement)
Example:
N=3
***
***
***
N=4
****
****
****
****

13. Write a program to accept an integer number and print the triangle as
below: (use loop statement)
Example:
N=3
*
**
***

N=4
*
**

2 92-Quang Trung –Da Nang. Tel: 05113.888 279


Java Assignment
***
****

14. Write a program to accept an integer number and print the triangle as
below: (use loop statement)

Example:
N=3
*
**
***

N=4
*
**
***
****
The End

You might also like