Week 10 : Programming Assignment 1
Program to sort the elements of an array in ascending order. Follow the naming convention as given in the main method of the suffix code.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 6
-5 -9 8 12 1 3 | Elements of array sorted in ascending order:\n
-9 -5 1 3 8 12 | Elements of array sorted in ascending order:\n
-9 -5 1 3 8 12 | Passed after ignoring Presentation Error |
Week 10 : Programming Assignment 2
Due on 2024-04-04, 23:59 IST
Print a given matrix in spiral form. Follow the naming convention as given in the main method of the suffix code.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 5
6 3 2 1 4
7 8 3 12 9
1 11 10 5 8
5 18 6 9 14
19 23 3 12 11 | 6 3 2 1 4 9 8 14 11 12 3 23 19 5 1 7 8 3 12 5 9 6 18 11 10 | 6 3 2 1 4 9 8 14 11 12 3 23 19 5 1 7 8 3 12 5 9 6 18 11 10 | Passed after ignoring Presentation Error |
Week 10 : Programming Assignment 3
Due on 2024-04-04, 23:59 IST
Code to create two threads, one printing even numbers and the other printing odd numbers.
Follow the naming convention as given in the main method of the suffix code.
- The PrintNumbers class is declared, and it implements the Runnable interface. This interface is part of Java's concurrency support and is used to represent a task that can be executed concurrently by a thread.
- Create a constructor of this class that takes two private instance variables (start and end) to represent the range of numbers that will be printed by the thread.
- Create a run method that is required by the Runnable interface and contains the code that will be executed when the thread is started. In this case, it should prints odd numbers within the specified range (start to end) using a for loop.
- Hints: Thread.currentThread().getName() returns the name of the currently executing thread, which is useful for identifying which thread is printing the numbers.
Follow the naming convention as given in the main method of the suffix code.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 2
10
3
7 | EvenThread: 2\n
EvenThread: 4\n
EvenThread: 6\n
EvenThread: 8\n
EvenThread: 10\n
OddThread: 3\n
OddThread: 5\n
OddThread: 7 | EvenThread: 2\n
EvenThread: 4\n
EvenThread: 6\n
EvenThread: 8\n
EvenThread: 10\n
OddThread: 3\n
OddThread: 5\n
OddThread: 7\n
| Passed after ignoring Presentation Error |
Week 10 : Programming Assignment 4
Due on 2024-04-04, 23:59 IST
Program to compute the sum of all prime numbers in a given range.
The range value will be positive.
Follow the naming convention as given in the main method of the suffix code.The range value will be positive.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 4
13 | 36 | 36\n
| Passed after ignoring Presentation Error |
Week 10 : Programming Assignment 5
Due on 2024-04-04, 23:59 IST
Write a program that converts temperatures between Celsius and Fahrenheit. Implement two methods, celsiusToFahrenheit and fahrenheitToCelsius, to perform the conversions.
Follow the naming convention as given in the main method of the suffix code.- Use exception handling to handle invalid input temperatures (if celsius < -273.15 and fahrenheit < -459.67 , program should throw exception error).
- The TemperatureConverter class contains two methods for temperature conversion (celsiusToFahrenheit and fahrenheitToCelsius).
- The TemperatureException class is a custom exception class that extends Exception and is used to handle invalid temperatures.
- The TemperatureConverterApp class is the main class that takes user input for temperatures and handles potential exceptions during the conversion process.
- celsiusToFahrenheit = (celsius * 9 / 5) + 32
- fahrenheitToCelsius = (fahrenheit - 32) * 5 / 9
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | -278 | Error: Invalid Celsius temperature (below absolute zero) | Error: Invalid Celsius temperature (below absolute zero)\n
| Passed after ignoring Presentation Error |
Test Case 2 | -1
-500 | Temperature in Fahrenheit: 30.2\n
Error: Invalid Fahrenheit temperature (below absolute zero) | Temperature in Fahrenheit: 30.2\n
Error: Invalid Fahrenheit temperature (below absolute zero)\n
| Passed after ignoring Presentation Error |
Test Case 3 | 45
112 | Temperature in Fahrenheit: 113.0\n
Temperature in Celsius: 44.44444444444444 | Temperature in Fahrenheit: 113.0\n
Temperature in Celsius: 44.44444444444444\n
| Passed after ignoring Presentation Error |
No comments