0% found this document useful (0 votes)
5 views2 pages

Lab - Introduction

The document outlines programming exercises for COSC2440 - Further Programming, focusing on Java. It includes tasks such as sorting integers, checking divisibility, displaying numbers in a specific format, creating a conversion table, generating a pyramid pattern, and determining the relationship between two circles. Each exercise is designed to reinforce programming concepts and user input handling.

Uploaded by

nphuyen.personal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Lab - Introduction

The document outlines programming exercises for COSC2440 - Further Programming, focusing on Java. It includes tasks such as sorting integers, checking divisibility, displaying numbers in a specific format, creating a conversion table, generating a pyramid pattern, and determining the relationship between two circles. Each exercise is designed to reinforce programming concepts and user input handling.

Uploaded by

nphuyen.personal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

RMIT Classification: Trusted

COSC2440 - Further Programming

Introduction to Java (1)


1. Write a program that get three integers from the user and then prints them out in
ascending order.

2. Write a program that repeatedly prompts the user to enter a positive integer and checks
whether the number is divisible by both 5 and 6, or neither of them, or just one of
them. The program ends when the user enters a negative integer or zero.

Sample run:

Enter a positive integer: 10


10 is divisible by 5 or 6, but not both
Enter a positive integer: 30
30 is divisible by both 5 and 6
Enter a positive integer: 23
23 is neither divisible by 5 nor 6
Enter a positive integer: -1
Goodbye!

3. Write a program that displays all the numbers from 100 to 200, ten numbers per line,
that are divisible by 5 or 6, but not both. Numbers are separated by exactly one space.

4. Write a program that uses a suitable loop to display a conversion table nicely as the one
below, knowing that 1 mile is 1.609 kilometers. Hint: use System.out.printf().

1
RMIT Classification: Trusted

5. Write a program that prompts the user to enter an integer from 1 to 15 and displays a
pyramid, as shown in the following sample run:

6. Write a program that prompts the user to enter the center coordinates and radiuses of
two circles and determines whether the second circle is inside the first or overlaps with
the first, as shown in the below Figure.

Hint: circle2 is inside circle1 if the distance between the two centers <= |r1 - r2| and
circle2 overlaps circle1 if the distance between the two centers <= r1 + r2
Test your program to cover all cases.

(a) A circle is inside another circle. (b) A circle overlaps another circle

Sample run:

You might also like