SlideShare a Scribd company logo
2
Q-14 Given a non-negative int n, return the sum of its digits recursively (no loops). Note that mod
(%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost
digit (126 / 10 is 12).
*Q-15 Given a non-negative int n, return the count of the occurrences of 7 as a digit, so for
example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is
6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).
Q-16 Write a program to find the number of and sum of all integers greater than 200 that are
divisible by 7.
*Q-17 Given any number, write a program using while loop to reverse the digits of the number.
Q-18 Write a program to determine the sum of the following harmonic series for a given value of
n:
1+1/2+1/3+ ----- +1/n The value of n should be given interactively through the keyboard.
*Q-19 Write a program that computes the area of a triangle. The sides of triangle should be given
interactively through the keyboard.
*Q-20 Write a program to sort any list of given numbers.
*Q-21 Write a program to add two 3 by 3 matrices.
Day 4, 5, 6: Inheritance programming techniques
Q-22 Write a java code to find the distance from Ranchi to major cities of India.
Hint: Create an String array of major cities and integer array of distances. User
gives the city name and the same is searched (use binary search) in the respective
array and displays result.
Q-23 Write a Patient class which inherits from the Person class. You may also need to
use the Money class. The Patient class requires the following:
• a variable to store the patient number for the patient
• a variable to store the hospital
• a variable to store the patient 's year of joining the hospital
• a variable to store the patient 's address
• a variable to store the medical fees that the patient pays
• constructor methods, which initialise the variables
• methods to set the hospital , year of joining and address
• methods to get the hospital, year of joining and address
• a method to calculate the medical fees : It should take a Money object (the basic fee per
year) as a parameter and use it to return the basic fee for the patient. A patient should
pay the basic fee for the year of R 1200, 50.
• a toString method
Q-24: a. Explain the difference between early and late/dynamic binding.
b. Which keyword can be used to indicate that a method cannot be overridden with
Most read
3
a new definition in a derived class?
c. Give the code for an abstract method called getArea() that calculates and returns
the area of a shape as a double.
Q-25: A small company dealing with transportation has just purchased a computer for
its new automated reservations system. You have been asked to program the new
system. You are to write a program called ReservationSystem to assign seats on a
vehicle. Your class also requires the following:
a constructor method, which initialise the variables
a method to assign the capacity of seating.
a method for assigning seats. Use a 1-d array to represent the seating chart of the plane.
Initialize all the elements of the array to 0 to indicate that all the seats are empty. As
each seat is assigned, set the corresponding elements of the array to 1 to indicate that
the seat is no longer available. Your program should, of course never assign a seat that
has already been assigned.
appropriate mutator and accessor methods
The company also needs a program dealing especially with its only plane with each
flight having a capacity of 10 seats. Name this class AirlineReservationSystem. This
class is a type of ReservationSystem but the way it reserves seats are different.
Your program should display the following menu of alternatives for reserving a seat on
the flight:
Please type 1 for “smoking”
Please type 2 for “non-smoking”
If the person types 1,then your program should assign a seat in the smoking
section(seats 1-5) If the person types 2,then your program should assign a seat in the
non-smoking section(seats 6-10). Your program should then print a boarding pass
indicating the person’s seat number and whether it is in the smoking or non-smoking
section of the plane.
When the smoking section is full, your program should ask the person if it is
acceptable to be placed in the non-smoking section (and vice versa). If yes, then make
the appropriate seat assignment. If no, then print the message “Next flight leaves in 3
hours.”
Create a main() method to test the next scheduled flight.
Q-26:
• Create a superclass, Student, and two subclasses, Undergrad and Grad.
• The superclass Student should have the following data members: name, ID, grade, age,
and address.
• The superclass, Student should have at least one method: boolean isPassed (double
grade)
Most read
4
The purpose of the isPassed method is to take one parameter, grade (value between 0 and
100) and check whether the grade has passed the requirement for passing a course. In the
Student class this method should be empty as an abstract method.
• The two subclasses, Grad and Undergrad, will inherit all data members of the Student
class and override the method isPassed. For the UnderGrad class, if the grade is above
70.0, then isPassed returns true, otherwise it returns false. For the Grad class, if the
grade is above 80.0, then isPassed returns true, otherwise returns false.
• Create a test class for your three classes. In the test class, create one Grad object and
one Undergrad object. For each object, provide a grade and display the results of the
isPassed method.
Q-27: a. How do you use the scope of class members and methods to hide information
from other classes?
b. When should you use inheritance programming techniques to solve problems?
c. What are the benefits of using inheritance? To save time? Shorter programs?
d. Java can deal with single inheritance (one superclass with multiple subclasses). How
can a class inherit from more than one superclass (multiple inheritances)?
Q-28: Create an applet program for Banner; banner text (Your Roll No.) should be
passed as parameter. This applet creates a thread that scrolls the message
contained in message right to left across the applet's window & also uses status
window.
Q-29: Create an applet program for Menu demonstration. Menu bar should contain
File, Edit, View and its submenus.
Q-30: Create Labels (One, Two & Three), add Buttons (Yes, No, Undecided) when
user click any button show message regarding user click, add
Checkboxes(Windows 98/XP, Windows NT/2000) when user chose any
checkbox show message regarding user choice & add text boxes (name,
password) and text on these textboxes should be displayed on Panel.
Q-31: Draw colour lines, Rectangle, Filled Rectangle, Rounded Rectangle, Filled
Rounded Rectangle, Oval, Filled oval, arc, fill arc, & polygon every drawing
shape should be in different colour, Write a text “hello everyone” at the center.
Q-32: Create an applet program for key events it should recognize normal as well as
special keys & should be displayed on the panel.
Q-33: Create an applet program for mouse events it should recognize mouse entry, exit,
and its coordinates.
Tip: When a web page is to be developed, the following are to be planned:
1. Content of the page
2. Appearance of the page
Appearance of the page is coded in HTML using HTML tags.
Most read
JAVA PROGRAMMING LAB ASSIGNMENTS
Q-1 The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are
on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.
Q-2 Given two int values, return their sum. Unless the two values are the same, then return double
their sum.
Q-3 Given an int n, return the absolute difference between n and 21, except return double the
absolute difference if n is over 21.
*Q-4 Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10.
*Q-5 Given 2 int values, return true if one is negative and one is positive. Unless negative is true,
then they both must be negative.
Q-6 Given a string, return a new string where the first and last chars have been exchanged.
frontBack("code") → "eodc"
frontBack("a") → "a"
frontBack("ab") → "ba"
Q-7 Given a string, take the last char and return a new string with the last char added at the front
and back, so "cat" yields "tcatt". The original string will be length 1 or more.
backAround("cat") → "tcatt"
backAround("Hello") → "oHelloo"
backAround("a") → "aaa"
*Q-8 Given a string, return true if the string starts with "hi" and false otherwise.
Q-9 Given three int values, A B C, return the largest.
Q-10 Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or
return 0 if neither is in that range.
*Q-11 Given a string, return a new string where the last 3 chars are now in upper case. If the string
has less than 3 chars, uppercase whatever is there. Note that str.toUpperCase() returns the
uppercase version of a string.
Q-12 Given n of 1 or more, return the factorial of n, which is n * (n-1) * (n-2) ... 1. Compute the
result recursively (without loops).
Q-13 The fibonacci sequence is a famous bit of mathematics, and it happens to have a recursive
definition. The first two values in the sequence are 0 and 1 (essentially 2 base cases). Each
subsequent value is the sum of the previous two values, so the whole sequence is: 0, 1, 1, 2, 3, 5, 8,
13, 21 and so on. Define a recursive fibonacci(n) method that returns the nth fibonacci number,
with n=0 representing the start of the sequence.
Q-14 Given a non-negative int n, return the sum of its digits recursively (no loops). Note that mod
(%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost
digit (126 / 10 is 12).
*Q-15 Given a non-negative int n, return the count of the occurrences of 7 as a digit, so for
example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is
6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).
Q-16 Write a program to find the number of and sum of all integers greater than 200 that are
divisible by 7.
*Q-17 Given any number, write a program using while loop to reverse the digits of the number.
Q-18 Write a program to determine the sum of the following harmonic series for a given value of
n:
1+1/2+1/3+ ----- +1/n The value of n should be given interactively through the keyboard.
*Q-19 Write a program that computes the area of a triangle. The sides of triangle should be given
interactively through the keyboard.
*Q-20 Write a program to sort any list of given numbers.
*Q-21 Write a program to add two 3 by 3 matrices.
Day 4, 5, 6: Inheritance programming techniques
Q-22 Write a java code to find the distance from Ranchi to major cities of India.
Hint: Create an String array of major cities and integer array of distances. User
gives the city name and the same is searched (use binary search) in the respective
array and displays result.
Q-23 Write a Patient class which inherits from the Person class. You may also need to
use the Money class. The Patient class requires the following:
• a variable to store the patient number for the patient
• a variable to store the hospital
• a variable to store the patient 's year of joining the hospital
• a variable to store the patient 's address
• a variable to store the medical fees that the patient pays
• constructor methods, which initialise the variables
• methods to set the hospital , year of joining and address
• methods to get the hospital, year of joining and address
• a method to calculate the medical fees : It should take a Money object (the basic fee per
year) as a parameter and use it to return the basic fee for the patient. A patient should
pay the basic fee for the year of R 1200, 50.
• a toString method
Q-24: a. Explain the difference between early and late/dynamic binding.
b. Which keyword can be used to indicate that a method cannot be overridden with
a new definition in a derived class?
c. Give the code for an abstract method called getArea() that calculates and returns
the area of a shape as a double.
Q-25: A small company dealing with transportation has just purchased a computer for
its new automated reservations system. You have been asked to program the new
system. You are to write a program called ReservationSystem to assign seats on a
vehicle. Your class also requires the following:
a constructor method, which initialise the variables
a method to assign the capacity of seating.
a method for assigning seats. Use a 1-d array to represent the seating chart of the plane.
Initialize all the elements of the array to 0 to indicate that all the seats are empty. As
each seat is assigned, set the corresponding elements of the array to 1 to indicate that
the seat is no longer available. Your program should, of course never assign a seat that
has already been assigned.
appropriate mutator and accessor methods
The company also needs a program dealing especially with its only plane with each
flight having a capacity of 10 seats. Name this class AirlineReservationSystem. This
class is a type of ReservationSystem but the way it reserves seats are different.
Your program should display the following menu of alternatives for reserving a seat on
the flight:
Please type 1 for “smoking”
Please type 2 for “non-smoking”
If the person types 1,then your program should assign a seat in the smoking
section(seats 1-5) If the person types 2,then your program should assign a seat in the
non-smoking section(seats 6-10). Your program should then print a boarding pass
indicating the person’s seat number and whether it is in the smoking or non-smoking
section of the plane.
When the smoking section is full, your program should ask the person if it is
acceptable to be placed in the non-smoking section (and vice versa). If yes, then make
the appropriate seat assignment. If no, then print the message “Next flight leaves in 3
hours.”
Create a main() method to test the next scheduled flight.
Q-26:
• Create a superclass, Student, and two subclasses, Undergrad and Grad.
• The superclass Student should have the following data members: name, ID, grade, age,
and address.
• The superclass, Student should have at least one method: boolean isPassed (double
grade)
The purpose of the isPassed method is to take one parameter, grade (value between 0 and
100) and check whether the grade has passed the requirement for passing a course. In the
Student class this method should be empty as an abstract method.
• The two subclasses, Grad and Undergrad, will inherit all data members of the Student
class and override the method isPassed. For the UnderGrad class, if the grade is above
70.0, then isPassed returns true, otherwise it returns false. For the Grad class, if the
grade is above 80.0, then isPassed returns true, otherwise returns false.
• Create a test class for your three classes. In the test class, create one Grad object and
one Undergrad object. For each object, provide a grade and display the results of the
isPassed method.
Q-27: a. How do you use the scope of class members and methods to hide information
from other classes?
b. When should you use inheritance programming techniques to solve problems?
c. What are the benefits of using inheritance? To save time? Shorter programs?
d. Java can deal with single inheritance (one superclass with multiple subclasses). How
can a class inherit from more than one superclass (multiple inheritances)?
Q-28: Create an applet program for Banner; banner text (Your Roll No.) should be
passed as parameter. This applet creates a thread that scrolls the message
contained in message right to left across the applet's window & also uses status
window.
Q-29: Create an applet program for Menu demonstration. Menu bar should contain
File, Edit, View and its submenus.
Q-30: Create Labels (One, Two & Three), add Buttons (Yes, No, Undecided) when
user click any button show message regarding user click, add
Checkboxes(Windows 98/XP, Windows NT/2000) when user chose any
checkbox show message regarding user choice & add text boxes (name,
password) and text on these textboxes should be displayed on Panel.
Q-31: Draw colour lines, Rectangle, Filled Rectangle, Rounded Rectangle, Filled
Rounded Rectangle, Oval, Filled oval, arc, fill arc, & polygon every drawing
shape should be in different colour, Write a text “hello everyone” at the center.
Q-32: Create an applet program for key events it should recognize normal as well as
special keys & should be displayed on the panel.
Q-33: Create an applet program for mouse events it should recognize mouse entry, exit,
and its coordinates.
Tip: When a web page is to be developed, the following are to be planned:
1. Content of the page
2. Appearance of the page
Appearance of the page is coded in HTML using HTML tags.
Q-34: Design a HTML page (web page) describing your profile in one paragraph.
Design in such a way that it has a heading, a horizontal rule, three links and a
photo of your institution. Also, write three HTML documents for the links.
Q-35: Prepare a HTML page listing popular car companies. For each company prepare
a sub-list showing various brands of cars it offers.
Q-36: Write a HTML document to draw the following table.
Prices of flats in Chennai 2006
Area Type of house Rate in
rupees/sq. ft.
Annanagar
Ordinary 1800
Delux 1950
Adyar
Ordinary 2450
Delux 2775
Egmore
Ordinary 2000
Delux 2125
Q-37: Write a HTML document/page that has 3 frames. The window must be row
wise divided into two frames first and the bottom frame is divided into two
frames column wise.
Q-38: Write a HTML document showing a password field. When password is
entered, the asterisk symbols must be displayed in place of password in the
input field.
Q-39: Design the following form using HTML.
Q-40: Write HTML/Javascript code for the page showing check boxes, text box and
submit button. The user selects the check box(es) and once the user clicks
submit button the selected check box items appear in the text box.
Q-41: Write HTML/Javascript code for the page showing currency conversion. The
user enters the amount in rupees in the text box and selects a patrticular radio
button for the currency conversion. On checking it must display the amount
in the corresponding currency.
Q-42: Write HTML/Javascript code for the page showing a select box and a text box.
The select box contains a list of names. When the user selects a name from
the select box the corresponding phone number appears in the phone number
Application for Admission
Name
DOB
O Male
O Female
SUBMIT
input box.
Q-43: Write HTML/Javascript code for the page having three text boxes and a
submit button. The three text boxes are email id, age and name. The email id
text box has to contain @ symbol, age should be greater than 1 and less than
or equal to 100 and name should not exceed 10 characters. If the email id
doesnot contain @ symbol an alert message is fired. Similarly for age and
name the corresponfing alert message is fired.
JAVA Assignment
1. Create a new Java class named Car that has the following fields
o year - The year field is an int that holds a car's year model (e.g.
2010)
o make - The make field is a String object that holds the make of
the car (e.g. "Porsche")
o speed - The speed field is an double that holds a car's current
speed (e.g. 25.0)
In addition, the Car class should have the following methods.
o Constructor - The constructor should accept the car's year, make,
and beginning speed as arguments
 These values should be used to initialize the Car's year,
make, and speed fields
o Getter Methods - Write three accessor (getter) methods to get the
values stored in an object's fields
 getYear(), getMake(), getSpeed()
o accelerate - Write an accelerate method that has no arguments
(parameters) passed to it and adds 1 to the speed field each time it
is called
 For example: if the car was going 3 mph, accelerate would set
the speed to 4 mph
Write a main method that uses your Car class
1. Write a separate Java class RaceTrack in file RaceTrack.java with
a main method that uses your Car class
o Save the class in file RaceTrack.java in folder U:labslab5
2. Inside RaceTrack class' main method
o Create a new Car object (using the Car constructor method), passing
in the year, make, and speed
o Display the current status of the car object using
the getter methods getYear(), getMake(), and getSpeed()
o Call the car's accelerate method and then re-display the car's speed
using getSpeed()
o
3. Create a new Java file named Pay.java with following variables
double hoursWorked,double hourlyPayRate,double grossPay;
calculate gross salary as below
hoursworked <=40 then calculate
hoursWorked * hourlyPayRate
otherwise calculated as below
hoursWorked) * (1.5 * hourlyPayRate));
While the Pay program may now calculate gross pay correctly, in the real
world, nothing can be said to be certain except death and taxes. Assume
that the tax man takes a flat 33% of gross wages as taxes.
4. Write a program that calculates how much a person would earn over a
period of time if his or her yearly salary begins at $1,000.00 the first
year, $2,000.00 the second year, and continues to double each
year.Add a running total to your program to keep track of their total
pay received over the years.Display the total pay and average salary
received
5 . Create a class as per the requirement whih Convert the starting time in
hours and minutes to the equivalent total_minutes
o For example: 2 hours and 30 minutes would be 150 total minutes
o For example: 5 hours and 15 minutes would be 315 total minutes
o Hint: use multiplication and addition
Write down the math formula needed to calculate the ending time (in total
minutes) given the starting time (in total minutes) and the duration (in
minutes).
endingTime (in total minutes) = write out the formula
Convert the ending time in total minutes back to hours and minutes
with / and % integer operators and the fact that one hour is 60 minutes
o For example, 63 minutes is 1 hour and 3 minutes
o For example, 125 minutes is 2 hours and 5 minutes
o For example, 325 minutes is 5 hours and 25 minutes
On the Lab 3 assignment sheet, write down the math formula needed to
calculate the ending hour and minutes given the ending time (in total minutes).
Note: at this point, assume simple military time for the end hours. So
12:50 plus 30 minutes would be 13:20
endingHour = write out the formula
endingMinutes = write out the formula
EndingTime.java
Write the Java program EndingTime.java that calculates the ending time (in
hours and minutes), given a starting time (in hours and minutes) and a
duration (in minutes).
Sample Session
Enter the starting time (in hours and minutes): 2 30
Enter the duration (in minutes): 125
Ending hour is 4
Ending minute is 35
6. Write a Java program named NameMaker.java with the String
variables firstName, middleName, lastName, and fullName. Prompt the user
to enter their first, middle, and last names and read the names from
the keyboard. Use string concatenation to set and display their fullName as
firstName + a blank char + middleName + a blank char + lastName
Also Use String methods to
o Display their initials
o Display their full name in all uppercase letters
o Display their full name in all lowercase letters
o Display the number of characters in their full name, including
blank spaces
7. Write a LandTract Java class that holds a tract's length and width (as
doubles)
• Write the class constructor method that accepts two double
arguments, one for the track's length and one for the width
• Write the getArea method that returns the tract's area
o area = length * width
• Write an equals method that accepts a LandTract object as the
parameter and returns true if the two tracks have the same area,
otherwise false
8. Body mass index (BMI) is a measure of body fat based on height and weight
that applies to adult men and women. BMI can be used to indicate if you are
overweight, obese, underweight or normal.
Women tend to believe they look their best at BMI values between 20 to 22
and men are usually satisfied with a BMI of 23 to 25.
If your BMI is 30 or more, that's not good. However, the simple BMI calculation
tends to overestimate BMI in people who are muscular or athletic. Therefore, if
your BMI score seems too high, you're not too fat, your just too athletic.
BMI is calculated based on a person's weight and height. The math formula for
calculating BMI is shown at right
Simple BMI categories include
• Underweight when BMI is less than 18.5
• Normal weight when BMI is between 18.5 and 25
• Overweight when BMI is between 25 and 30
• Too Muscular (Obese) when BMI is 30 or greater
Now Write the Java program that
o Declares variables used in the program
o Creates a Scanner object
o Gets the user's weight (in pounds) and height (in inches)
o Calculates their Body Mass Index (BMI)
o Displays the results

More Related Content

What's hot (20)

OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
Ranjith Sekar
 
Get and post methods
Get and post methodsGet and post methods
Get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
Use case of hospital managment system
Use case of hospital managment systemUse case of hospital managment system
Use case of hospital managment system
Mohin Uddin Majumder (Sanofi Mohin)
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
Monotheist Sakib
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
princeirfancivil
 
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
Beat Signer
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
Introduction to Hadoop
Introduction to HadoopIntroduction to Hadoop
Introduction to Hadoop
Dr. C.V. Suresh Babu
 
SRS for smart health care system,srs for health system,health management doc...
SRS  for smart health care system,srs for health system,health management doc...SRS  for smart health care system,srs for health system,health management doc...
SRS for smart health care system,srs for health system,health management doc...
AnilkumarSingh129
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Iqra khalil
 
ARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCEARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCE
Sabique Khan
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
vishal choudhary
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Online course reservation system
Online course reservation systemOnline course reservation system
Online course reservation system
Chamma Jabeedkhan
 
3 Data Mining Tasks
3  Data Mining Tasks3  Data Mining Tasks
3 Data Mining Tasks
Mahmoud Alfarra
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat
 
Online examination system
Online examination systemOnline examination system
Online examination system
Mr. Vikram Singh Slathia
 
Introduction to HDFS
Introduction to HDFSIntroduction to HDFS
Introduction to HDFS
Bhavesh Padharia
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
Monotheist Sakib
 
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
XML and XML Applications - Lecture 04 - Web Information Systems (WE-DINF-11912)
Beat Signer
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
SRS for smart health care system,srs for health system,health management doc...
SRS  for smart health care system,srs for health system,health management doc...SRS  for smart health care system,srs for health system,health management doc...
SRS for smart health care system,srs for health system,health management doc...
AnilkumarSingh129
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Iqra khalil
 
ARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCEARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCE
Sabique Khan
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
vishal choudhary
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Online course reservation system
Online course reservation systemOnline course reservation system
Online course reservation system
Chamma Jabeedkhan
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat
 

Viewers also liked (20)

Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
Mumbai Academisc
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
 
Java Notes
Java NotesJava Notes
Java Notes
Abhishek Khune
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
trupti1976
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and Polymorphism
Eduardo Bergavera
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)
akmalfahmi
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
trupti1976
 
Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]Pf cs102 programming-9 [pointers]
Pf cs102 programming-9 [pointers]
Abdullah khawar
 
Apclass
ApclassApclass
Apclass
geishaannealagos
 
Apclass (2)
Apclass (2)Apclass (2)
Apclass (2)
geishaannealagos
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
Deepak Singh
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
Eduardo Bergavera
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
HNDE Labuduwa Galle
 
Loop c++
Loop c++Loop c++
Loop c++
Mood Mood
 
C++ programming (Array)
C++ programming (Array)C++ programming (Array)
C++ programming (Array)
طارق بالحارث
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
Appili Vamsi Krishna
 
Array in c++
Array in c++Array in c++
Array in c++
Mahesha Mano
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
Farhan Ab Rahman
 
Structure in c
Structure in cStructure in c
Structure in c
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Similar to Java programming lab assignments (20)

C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
 
Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
Gaurav Dixit
 
Array sheet
Array sheet Array sheet
Array sheet
Mahmoud Abuelmagd
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
India
 
C code examples
C code examplesC code examples
C code examples
Industrial Electric, Electronic Ind. And Trade Co. Ltd.
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
Programming Exam Help
 
Answer SheetInstructions You must show your work to .docx
Answer SheetInstructions  You must show your work to .docxAnswer SheetInstructions  You must show your work to .docx
Answer SheetInstructions You must show your work to .docx
justine1simpson78276
 
Computer Science Paper 1 (Theory) - 2017.pdf
Computer Science Paper 1 (Theory) - 2017.pdfComputer Science Paper 1 (Theory) - 2017.pdf
Computer Science Paper 1 (Theory) - 2017.pdf
AbhradeepDutta1
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
tiffanyd4
 
A01
A01A01
A01
lksoo
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
mecklenburgstrelitzh
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
sujatam8
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
gerardkortney
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
Sanjeev Mishra
 
Practical java
Practical javaPractical java
Practical java
nirmit
 
Cse cpl manual-2016
Cse cpl manual-2016Cse cpl manual-2016
Cse cpl manual-2016
Rajendra khatana
 
Programming qns
Programming qnsProgramming qns
Programming qns
Dr.Subha Krishna
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docx
Lucky Ally
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
scottbrownnn
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
Last7693
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
India
 
Answer SheetInstructions You must show your work to .docx
Answer SheetInstructions  You must show your work to .docxAnswer SheetInstructions  You must show your work to .docx
Answer SheetInstructions You must show your work to .docx
justine1simpson78276
 
Computer Science Paper 1 (Theory) - 2017.pdf
Computer Science Paper 1 (Theory) - 2017.pdfComputer Science Paper 1 (Theory) - 2017.pdf
Computer Science Paper 1 (Theory) - 2017.pdf
AbhradeepDutta1
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
tiffanyd4
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
mecklenburgstrelitzh
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
gerardkortney
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
Sanjeev Mishra
 
Practical java
Practical javaPractical java
Practical java
nirmit
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docx
Lucky Ally
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
scottbrownnn
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
Last7693
 
Ad

Recently uploaded (20)

Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 

Java programming lab assignments

  • 1. JAVA PROGRAMMING LAB ASSIGNMENTS Q-1 The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in. Q-2 Given two int values, return their sum. Unless the two values are the same, then return double their sum. Q-3 Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21. *Q-4 Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10. *Q-5 Given 2 int values, return true if one is negative and one is positive. Unless negative is true, then they both must be negative. Q-6 Given a string, return a new string where the first and last chars have been exchanged. frontBack("code") → "eodc" frontBack("a") → "a" frontBack("ab") → "ba" Q-7 Given a string, take the last char and return a new string with the last char added at the front and back, so "cat" yields "tcatt". The original string will be length 1 or more. backAround("cat") → "tcatt" backAround("Hello") → "oHelloo" backAround("a") → "aaa" *Q-8 Given a string, return true if the string starts with "hi" and false otherwise. Q-9 Given three int values, A B C, return the largest. Q-10 Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range. *Q-11 Given a string, return a new string where the last 3 chars are now in upper case. If the string has less than 3 chars, uppercase whatever is there. Note that str.toUpperCase() returns the uppercase version of a string. Q-12 Given n of 1 or more, return the factorial of n, which is n * (n-1) * (n-2) ... 1. Compute the result recursively (without loops). Q-13 The fibonacci sequence is a famous bit of mathematics, and it happens to have a recursive definition. The first two values in the sequence are 0 and 1 (essentially 2 base cases). Each subsequent value is the sum of the previous two values, so the whole sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. Define a recursive fibonacci(n) method that returns the nth fibonacci number, with n=0 representing the start of the sequence.
  • 2. Q-14 Given a non-negative int n, return the sum of its digits recursively (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). *Q-15 Given a non-negative int n, return the count of the occurrences of 7 as a digit, so for example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). Q-16 Write a program to find the number of and sum of all integers greater than 200 that are divisible by 7. *Q-17 Given any number, write a program using while loop to reverse the digits of the number. Q-18 Write a program to determine the sum of the following harmonic series for a given value of n: 1+1/2+1/3+ ----- +1/n The value of n should be given interactively through the keyboard. *Q-19 Write a program that computes the area of a triangle. The sides of triangle should be given interactively through the keyboard. *Q-20 Write a program to sort any list of given numbers. *Q-21 Write a program to add two 3 by 3 matrices. Day 4, 5, 6: Inheritance programming techniques Q-22 Write a java code to find the distance from Ranchi to major cities of India. Hint: Create an String array of major cities and integer array of distances. User gives the city name and the same is searched (use binary search) in the respective array and displays result. Q-23 Write a Patient class which inherits from the Person class. You may also need to use the Money class. The Patient class requires the following: • a variable to store the patient number for the patient • a variable to store the hospital • a variable to store the patient 's year of joining the hospital • a variable to store the patient 's address • a variable to store the medical fees that the patient pays • constructor methods, which initialise the variables • methods to set the hospital , year of joining and address • methods to get the hospital, year of joining and address • a method to calculate the medical fees : It should take a Money object (the basic fee per year) as a parameter and use it to return the basic fee for the patient. A patient should pay the basic fee for the year of R 1200, 50. • a toString method Q-24: a. Explain the difference between early and late/dynamic binding. b. Which keyword can be used to indicate that a method cannot be overridden with
  • 3. a new definition in a derived class? c. Give the code for an abstract method called getArea() that calculates and returns the area of a shape as a double. Q-25: A small company dealing with transportation has just purchased a computer for its new automated reservations system. You have been asked to program the new system. You are to write a program called ReservationSystem to assign seats on a vehicle. Your class also requires the following: a constructor method, which initialise the variables a method to assign the capacity of seating. a method for assigning seats. Use a 1-d array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all the seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available. Your program should, of course never assign a seat that has already been assigned. appropriate mutator and accessor methods The company also needs a program dealing especially with its only plane with each flight having a capacity of 10 seats. Name this class AirlineReservationSystem. This class is a type of ReservationSystem but the way it reserves seats are different. Your program should display the following menu of alternatives for reserving a seat on the flight: Please type 1 for “smoking” Please type 2 for “non-smoking” If the person types 1,then your program should assign a seat in the smoking section(seats 1-5) If the person types 2,then your program should assign a seat in the non-smoking section(seats 6-10). Your program should then print a boarding pass indicating the person’s seat number and whether it is in the smoking or non-smoking section of the plane. When the smoking section is full, your program should ask the person if it is acceptable to be placed in the non-smoking section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message “Next flight leaves in 3 hours.” Create a main() method to test the next scheduled flight. Q-26: • Create a superclass, Student, and two subclasses, Undergrad and Grad. • The superclass Student should have the following data members: name, ID, grade, age, and address. • The superclass, Student should have at least one method: boolean isPassed (double grade)
  • 4. The purpose of the isPassed method is to take one parameter, grade (value between 0 and 100) and check whether the grade has passed the requirement for passing a course. In the Student class this method should be empty as an abstract method. • The two subclasses, Grad and Undergrad, will inherit all data members of the Student class and override the method isPassed. For the UnderGrad class, if the grade is above 70.0, then isPassed returns true, otherwise it returns false. For the Grad class, if the grade is above 80.0, then isPassed returns true, otherwise returns false. • Create a test class for your three classes. In the test class, create one Grad object and one Undergrad object. For each object, provide a grade and display the results of the isPassed method. Q-27: a. How do you use the scope of class members and methods to hide information from other classes? b. When should you use inheritance programming techniques to solve problems? c. What are the benefits of using inheritance? To save time? Shorter programs? d. Java can deal with single inheritance (one superclass with multiple subclasses). How can a class inherit from more than one superclass (multiple inheritances)? Q-28: Create an applet program for Banner; banner text (Your Roll No.) should be passed as parameter. This applet creates a thread that scrolls the message contained in message right to left across the applet's window & also uses status window. Q-29: Create an applet program for Menu demonstration. Menu bar should contain File, Edit, View and its submenus. Q-30: Create Labels (One, Two & Three), add Buttons (Yes, No, Undecided) when user click any button show message regarding user click, add Checkboxes(Windows 98/XP, Windows NT/2000) when user chose any checkbox show message regarding user choice & add text boxes (name, password) and text on these textboxes should be displayed on Panel. Q-31: Draw colour lines, Rectangle, Filled Rectangle, Rounded Rectangle, Filled Rounded Rectangle, Oval, Filled oval, arc, fill arc, & polygon every drawing shape should be in different colour, Write a text “hello everyone” at the center. Q-32: Create an applet program for key events it should recognize normal as well as special keys & should be displayed on the panel. Q-33: Create an applet program for mouse events it should recognize mouse entry, exit, and its coordinates. Tip: When a web page is to be developed, the following are to be planned: 1. Content of the page 2. Appearance of the page Appearance of the page is coded in HTML using HTML tags.
  • 5. Q-34: Design a HTML page (web page) describing your profile in one paragraph. Design in such a way that it has a heading, a horizontal rule, three links and a photo of your institution. Also, write three HTML documents for the links. Q-35: Prepare a HTML page listing popular car companies. For each company prepare a sub-list showing various brands of cars it offers. Q-36: Write a HTML document to draw the following table. Prices of flats in Chennai 2006 Area Type of house Rate in rupees/sq. ft. Annanagar Ordinary 1800 Delux 1950 Adyar Ordinary 2450 Delux 2775 Egmore Ordinary 2000 Delux 2125 Q-37: Write a HTML document/page that has 3 frames. The window must be row wise divided into two frames first and the bottom frame is divided into two frames column wise. Q-38: Write a HTML document showing a password field. When password is entered, the asterisk symbols must be displayed in place of password in the input field. Q-39: Design the following form using HTML. Q-40: Write HTML/Javascript code for the page showing check boxes, text box and submit button. The user selects the check box(es) and once the user clicks submit button the selected check box items appear in the text box. Q-41: Write HTML/Javascript code for the page showing currency conversion. The user enters the amount in rupees in the text box and selects a patrticular radio button for the currency conversion. On checking it must display the amount in the corresponding currency. Q-42: Write HTML/Javascript code for the page showing a select box and a text box. The select box contains a list of names. When the user selects a name from the select box the corresponding phone number appears in the phone number Application for Admission Name DOB O Male O Female SUBMIT
  • 6. input box. Q-43: Write HTML/Javascript code for the page having three text boxes and a submit button. The three text boxes are email id, age and name. The email id text box has to contain @ symbol, age should be greater than 1 and less than or equal to 100 and name should not exceed 10 characters. If the email id doesnot contain @ symbol an alert message is fired. Similarly for age and name the corresponfing alert message is fired.
  • 7. JAVA Assignment 1. Create a new Java class named Car that has the following fields o year - The year field is an int that holds a car's year model (e.g. 2010) o make - The make field is a String object that holds the make of the car (e.g. "Porsche") o speed - The speed field is an double that holds a car's current speed (e.g. 25.0) In addition, the Car class should have the following methods. o Constructor - The constructor should accept the car's year, make, and beginning speed as arguments  These values should be used to initialize the Car's year, make, and speed fields o Getter Methods - Write three accessor (getter) methods to get the values stored in an object's fields  getYear(), getMake(), getSpeed() o accelerate - Write an accelerate method that has no arguments (parameters) passed to it and adds 1 to the speed field each time it is called  For example: if the car was going 3 mph, accelerate would set the speed to 4 mph Write a main method that uses your Car class 1. Write a separate Java class RaceTrack in file RaceTrack.java with a main method that uses your Car class o Save the class in file RaceTrack.java in folder U:labslab5 2. Inside RaceTrack class' main method o Create a new Car object (using the Car constructor method), passing in the year, make, and speed o Display the current status of the car object using the getter methods getYear(), getMake(), and getSpeed() o Call the car's accelerate method and then re-display the car's speed using getSpeed() o 3. Create a new Java file named Pay.java with following variables double hoursWorked,double hourlyPayRate,double grossPay; calculate gross salary as below
  • 8. hoursworked <=40 then calculate hoursWorked * hourlyPayRate otherwise calculated as below hoursWorked) * (1.5 * hourlyPayRate)); While the Pay program may now calculate gross pay correctly, in the real world, nothing can be said to be certain except death and taxes. Assume that the tax man takes a flat 33% of gross wages as taxes. 4. Write a program that calculates how much a person would earn over a period of time if his or her yearly salary begins at $1,000.00 the first year, $2,000.00 the second year, and continues to double each year.Add a running total to your program to keep track of their total pay received over the years.Display the total pay and average salary received 5 . Create a class as per the requirement whih Convert the starting time in hours and minutes to the equivalent total_minutes o For example: 2 hours and 30 minutes would be 150 total minutes o For example: 5 hours and 15 minutes would be 315 total minutes o Hint: use multiplication and addition Write down the math formula needed to calculate the ending time (in total minutes) given the starting time (in total minutes) and the duration (in minutes). endingTime (in total minutes) = write out the formula Convert the ending time in total minutes back to hours and minutes with / and % integer operators and the fact that one hour is 60 minutes o For example, 63 minutes is 1 hour and 3 minutes o For example, 125 minutes is 2 hours and 5 minutes o For example, 325 minutes is 5 hours and 25 minutes On the Lab 3 assignment sheet, write down the math formula needed to calculate the ending hour and minutes given the ending time (in total minutes). Note: at this point, assume simple military time for the end hours. So 12:50 plus 30 minutes would be 13:20 endingHour = write out the formula
  • 9. endingMinutes = write out the formula EndingTime.java Write the Java program EndingTime.java that calculates the ending time (in hours and minutes), given a starting time (in hours and minutes) and a duration (in minutes). Sample Session Enter the starting time (in hours and minutes): 2 30 Enter the duration (in minutes): 125 Ending hour is 4 Ending minute is 35 6. Write a Java program named NameMaker.java with the String variables firstName, middleName, lastName, and fullName. Prompt the user to enter their first, middle, and last names and read the names from the keyboard. Use string concatenation to set and display their fullName as firstName + a blank char + middleName + a blank char + lastName Also Use String methods to o Display their initials o Display their full name in all uppercase letters o Display their full name in all lowercase letters o Display the number of characters in their full name, including blank spaces 7. Write a LandTract Java class that holds a tract's length and width (as doubles) • Write the class constructor method that accepts two double arguments, one for the track's length and one for the width • Write the getArea method that returns the tract's area o area = length * width • Write an equals method that accepts a LandTract object as the parameter and returns true if the two tracks have the same area, otherwise false
  • 10. 8. Body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. BMI can be used to indicate if you are overweight, obese, underweight or normal. Women tend to believe they look their best at BMI values between 20 to 22 and men are usually satisfied with a BMI of 23 to 25. If your BMI is 30 or more, that's not good. However, the simple BMI calculation tends to overestimate BMI in people who are muscular or athletic. Therefore, if your BMI score seems too high, you're not too fat, your just too athletic. BMI is calculated based on a person's weight and height. The math formula for calculating BMI is shown at right Simple BMI categories include • Underweight when BMI is less than 18.5 • Normal weight when BMI is between 18.5 and 25 • Overweight when BMI is between 25 and 30 • Too Muscular (Obese) when BMI is 30 or greater Now Write the Java program that o Declares variables used in the program o Creates a Scanner object o Gets the user's weight (in pounds) and height (in inches) o Calculates their Body Mass Index (BMI) o Displays the results