7 - Problem Assignments PDF
7 - Problem Assignments PDF
Class Outline:
Code:
package com;
TCS Internal
System.out.println("Student with highest marks is " +
compareStudents(one, two, three));
}
if(two.getMarks() >st.getMarks())
st = two;
return st.getName();
}
}
class Student
{
private int rollNo;
private String name;
private double marks;
}
Output:
TCS Internal
Each trainee is supposed to write above program and try out even if they are aware about
Java language. Along with learning Java numeric computations, below points are very
important to practice and applicable throughout this ILP training as well as most important for
any software code.
Use exactly same class names as mentioned
Use exactly same method signature (method name, return type, method parameter
type, position of each method parameter)
Define attributes with same name and data type as given in class outline.
Define constructors and getter setters as given in the class outline.
Ensure attributes are private and other methods which will be called from main method,
getter-setter methods and constructor is public.
Use main method only for input and output and testing object creation and object
methods.
As mentioned above, any logic which may be 100% correct is not valid if above points are not
taken care. Hence, simply building logic does not certify us as project ready. Building exact and
complete solution does.
Class Outline:
TCS Internal
3. Create class Car with below attributes:
make
model
passengerCapacity
onRoadPrice
Create class CarDemo which has main method. Create another method - getBestCar in this class
which will take four car objects and additional parameter as compareType. Value of this
parameter can be ‘c’ or ‘p’, where ‘c’ stands for capacity of passengers and ‘p’ stands for on road
price. This method will return make and model name for highest value of ‘c’ or ‘p’ (with –
character in between. E.g for make – Hyundai and model – santro, method should return
“Hyundai-santro”). Create four objects of Car class in main method and drive it through
getBestCar method.
Follow class outline diagram as given below. Ensure class attributes are private and other
methods are public. Use package “com” to build your solution.
Class Outline:
TCS Internal
4. Create class Customer with below attributes:
custId
accountId
creditCardCharges
Create another class CreditCardCompany which has a method which takes Customer object as
parameter and returns the payback amount for the credit card charges value for that customer.
Use below logic to calculate payback amount:
Create another class as CreditCardDemo which will have main method. Within main method,
create object of CreditCardCompany. Create 5 customer objects with relevant data. Call the
method to return payback amount for each customer and display the same
Follow class outline diagram as given below. Ensure class attributes are private and other
methods are public. Use package “com” to build your solution.
Class Outline:
TCS Internal