Week 09 : Programming Assignment 1
Write a Java program to display the number rhombus structure.
Input: n=2
Output:
1
212
1
(the output shown with the public test case has no spaces in the beginning,
its a fault of the swayam portal as it removes whitespaces before and after the output
you can write your program normally including spaces and it will be correct)
(passed with presentation error means you will always get full marks)
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 4 | 1\n
212\n
32123\n
4321234\n
32123\n
212\n
1 | 1\n
212\n
32123\n
4321234\n
32123\n
212\n
1\n
| Passed after ignoring Presentation Error |
Week 09 : Programming Assignment 2
Write a Java program to create an abstract class Person with abstract methods eat(), sleep() and exercise().
Create subclasses Athlete and LazyPerson that extend the Person class and implement the respective methods to describe how each person eats, sleeps and exercises.
Override the respective method in each subclass.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | NA | Athlete: Include foods full of calcium, iron, potassium, and fiber.\n
Athlete: Training allows the body to gradually build up strength and endurance, improve skill levels and build motivation, ambition and confidence.\n
Athlete: sleeps for 8 hours.\n
Couch Potato: Eating while watching TV also prolongs the time period that we're eating.\n
Couch Potato: Rarely exercising or being physically active.\n
Couch Potato: sleeps for 12 hours. | Athlete: Include foods full of calcium, iron, potassium, and fiber.\n
Athlete: Training allows the body to gradually build up strength and endurance, improve skill levels and build motivation, ambition and confidence.\n
Athlete: sleeps for 8 hours.\n
Couch Potato: Eating while watching TV also prolongs the time period that we're eating.\n
Couch Potato: Rarely exercising or being physically active.\n
Couch Potato: sleeps for 12 hours.\n
| Passed after ignoring Presentation Error |
Week 09 : Programming Assignment 3
Write a Java program to create a base class Shape with methods draw() and calculateArea().
Create two subclasses Circle and Cylinder.
Override the draw() method in each subclass to draw the respective shape.
In addition, override the calculateArea() method in the Cylinder subclass to calculate and return the total surface area of the cylinder.
(Remember to match the output given exactly, including the spaces and new lines)
(passed with presentation error means you will always get full marks)
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 2
3 | Drawing a circle\n
Area: 12.5664\n
Drawing a cylinder\n
Area: 62.8319 | Drawing a circle\n
Area: 12.5664\n
Drawing a cylinder\n
Area: 62.8319\n
| Passed after ignoring Presentation Error |
Week 09 : Programming Assignment 4
Write a Java program to create a class called "ElectronicsProduct" with attributes for product ID, name, and price.
Implement methods to apply a discount and calculate the final price.
Create a subclass " WashingMachine" that adds a warranty period attribute and a method to extend the warranty.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | w34
whirlpool
800
12
10 | Discount applied to Washing Machine: whirlpool\n
Product ID: w34\n
Name: whirlpool\n
Price after discount: $720.0\n
Warranty period: 12 months\n
Warranty period after extension: 24 months | Discount applied to Washing Machine: whirlpool\n
Product ID: w34\n
Name: whirlpool\n
Price after discount: $720.0\n
Warranty period: 12 months\n
Warranty period after extension: 24 months | Passed |
Week 09 : Programming Assignment 5
Write a Java program to find the length of the longest sequence of zeros in binary representation of an integer.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 12546 | 6 | 6 | Passed |
Private Test cases used for Evaluation | Status |
Test Case 1 | Passed |