This repository contains solutions for the Compact Programming assignment as part of the FH Dortmund online course on Java programming.
The assignment is divided into four tasks, each focusing on a different aspect of Java basics, object handling, and algorithms.
Each task was implemented individually by group members, and the final solutions are documented here.
Problem:
Readings: Language Basics: Variables, Operators, Expressions, Statements, and Blocks
The diameter of the Sun is approximately 865,000 miles. The diameter of the Earth is
approximately 7600 miles. Use the methods in the class Math to calculate,
(a) the volume of the Earth in cubic miles
(b) the volume of the Sun in cubic miles
(c) the ratio of the volume of the Sun to the volume of the Earth
and then output the three values. Treat both the earth and sun as spheres. The volume of a
sphere is given by the formula 4 pi r^3/3 where r is the radius.
Implemented by: Dnyaneshwar
Problem:
Readings: Language Basics : Control Flow Statements
Rewrite a program that prints prime numbers up to a given limit with the following requirements:
- Use a labeled continue instead of break.
- Do not use a Boolean isPrime variable.
- Only check divisors up to the square root of the number.
Implemented by: Adesh
Problem:
Readings: Object Basics and Simple Data Objects, The Life Cycle of an Object,Characters and
Strings
In the following code the soliloquy is analyzed character by character to determine the vowels,
spaces and letters used. Fill in the code that computes the number of spaces, vowels, and
consonants.
Implemented by: Anil
Problem:
Readings: Object Basics and Simple Data Objects
Numbers
Arrays
Write a program that sets up a String variable with the soliloquy in the previous question,
extracts the words from the text and sorts them into alphabetical order. You may define
'words' however you wish (within reason), but provide your definition with your solution. You
can use the sorting method of your choice. The simplest one is the bubble sort, which works
as follows:
• Starting with the first element in the array compare successive elements (0 and 1, 1
and 2, 2 and 3, and so on).
• If the first element of any pair is greater than the second, interchange the two
elements.
• Repeat the process for the whole array until no interchanges are necessary. The array
elements will now be in ascending order.
• Run the program once you have written your code. Turn in your code, and the output
produced when the code runs
Implemented by: Harsha
- All Problem statement solutions: Java Assignments 1.docx
- Drive Link (video explanation of the solution): https://drive.google.com/drive/folders/1INbEoNOIywkATXxNOaSSbIDADDMPRnFk