Sunteți pe pagina 1din 14

LAB-3

Date of the Session: ___/___/___ Time of the Session: _____to______

LEARNING OUTCOMES
L.O.1: To understand and apply instantiation of a class
L.O.2: To use dot(.) operator to invoke members and methods of an instance
L.O.3: To be able to differentiate scope of variable w.r.t to static and instance methods
L.O.4: To be able to create objects of various classes from java API packages like javax.swing,
java.io
L.O.5: To implement inner classes in java.

1) Rakesh is participating in a Hackathon and it requires him to make a Login page. Help
him out by writing a program to create the page. It should look as follows: [L.O 4]

Writing space for the Problem:(For Student’s use only)


2) A Mathematics faculty in class started asking questions about finding out the square
root of a given number. He now put up a challenge to Satya to tell all the numbers
starting from 1 to the given number (say n). Write a program to help him find out the
square root of all those numbers: [ L.O 1]
Writing space for the Problem:(For Student’s use only)
3) You have a file which contains confidential data in it. You want to send that data to one
of your executives, but you need to send a duplicate copy. Copy the data from original
file to duplicate file and send it: [ L.O 4]
Writing space for the Problem:(For Student’s use only)
4) While on his duty, a traffic police had the task of checking the speed of vehicles. It is
given that if the speed is above 90kmph, there should be a fine of 1000/- imposed on
the vehicle. Help him out by creating a program to for imposing of the fine. (Create two
classes for police and speedcheck. All methods must be static): [ L.O 2,3]
Writing space for the Problem:(For Student’s use only)
5) Full moon occurs for every 29.52 days. The last full moon occurred on August 14th,2019.
Calculate next two full moon days without creating object of the class and calculate two
previous full moon days by creating object of the class: [ L.O 3]
Writing space for the Problem:(For Student’s use only)
6) Alex was asked to predict number of characters, words and lines in a file. He was just
given the file name. Help Alex to predict, by passing file name as command line
argument: [ L.O 4]
Writing space for the Problem:(For Student’s use only)
7) You are working in DELL company. You’ve been asked to develop a program for the
service center website of the company. It should contain Purchasing and Servicing
options (Consider them as classes). Purchase class contains purchaseInspiron and
purchaseAlienware methods, Service class contains serviceOfLaptop and serviceOfPc
methods. Both service and purchase classes are in class Dell. (Use Inner Classes):
[L.O 5]
Writing space for the Problem:(For Student’s use only)
8) University is accepting new admissions for the upcoming academic year. In order to be
accepted into the university, the student needs to submit their JEE mains scores. If their
total is greater than 80%, they can get into the university else they can’t get an
admission. [L.O 5]

Complete the given program:


class Result

public void displayResult()

//Fill this line

double tm=sd.TotalMarks();

if((tm/360)*100 >= 80)

System.out.println("Eligible for the admission in college");

else

System.out.println("Ineligible for admission");

public class StudentDetails

double Maths=100,Physics=100,Chemistry=100;

void setMarks(double Maths, double Physics, double Chemistry)

{
// Fill these lines

double TotalMarks()

//Fill this line

return totalMarks;

class InnerClass

public static void main(String[] args)

Result.StudentDetails rsd=new Result().new StudentDetails();


rsd.setMarks(108,89,98);

//FILL THIS LINE//

r.displayResult();

S-ar putea să vă placă și