060010301 – java programmingutu.ac.in/dcst/download/documents/prmscit060010301.pdf · 060010301...

13
060010301 – Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem Statements to be performed in laboratory Group Group of Students (Enrolment No) Group 1 DIV-A(001 to 031) DIV-B(002 to 048) Group 2 DIV-A(033 to 070) DIV-B(049 to 087) Group 3 DIV-A(072 to 126,074) DIV-B(088 to 127) Group - 1 Sr. No Allocated Hours List of Problems Objective 1. 3 1. Write a program to compute simple and compound interest. 2. Write a program to compute the area of a circle. 3. Write a program that prints the numbers between 17 and 100, that can be evenly divided by 17(Use while loop). 4. Write a program to find sum of integers greater than 100 and less than 200 that are divisible by 7 (Use for loop). Clear basic concepts of Java platform, program structure and control statements. 2. 2 5. Write a program that creates string variables called firstname, lastname and myName. Using concatenations, assigns the value of firstname and lastname into myName, and display it on screen. 6. Write a program which accept one string and display all the vowels from that string. 7. Write a program to input a string and print the same in alphabetical order. Usage of String class and different function 3. 3 8. Write a program to display the sum of two diagonals of the array of the two dimensional array. 9. Write a menu driven program using two dimensional arrays to perform matrix addition, subtraction and multiplication. The program asks the user to input the numbers of rows and columns for matrix A and matrix B. The user then enters the elements of each array. Concept of one and two dimension array. 4. 6 10. Write a program that contains a class called “Student” with data members for storing Clear the concept of class, object,

Upload: dinhkhuong

Post on 15-Feb-2018

236 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 1

060010301-Java ProgrammingProblem Statements to be performed in laboratory

Group Group of Students (Enrolment No)Group 1 DIV-A(001 to 031)

DIV-B(002 to 048)Group 2 DIV-A(033 to 070)

DIV-B(049 to 087)Group 3 DIV-A(072 to 126,074)

DIV-B(088 to 127)

Group - 1Sr.No

AllocatedHours

List of Problems Objective

1. 3 1. Write a program to compute simple andcompound interest.2. Write a program to compute the area of a circle.3. Write a program that prints the numbersbetween 17 and 100, that can be evenlydivided by 17(Use while loop).4. Write a program to find sum of integersgreater than 100 and less than 200 that aredivisible by 7 (Use for loop).

Clear basicconcepts of Java

platform,program

structure andcontrol

statements.

2. 2 5. Write a program that creates string variablescalled firstname, lastname and myName. Usingconcatenations, assigns the value of firstnameand lastname into myName, and display it onscreen.6. Write a program which accept one string anddisplay all the vowels from that string.7. Write a program to input a string and print thesame in alphabetical order.

Usage of Stringclass and

different function

3. 3 8. Write a program to display the sum of twodiagonals of the array of the two dimensionalarray.9. Write a menu driven program using twodimensional arrays to perform matrix addition,subtraction and multiplication. The programasks the user to input the numbers of rows andcolumns for matrix A and matrix B. The userthen enters the elements of each array.

Concept of oneand two

dimension array.

4. 6 10.Write a program that contains a class called“Student” with data members for storing Clear the conceptof class, object,

Page 2: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 2

student number, name, year of study; andmethods for accessing them. The programshould include a driver class with main()method which creates objects of student classand take user inputs and stores them inobjects. The program should display content ofobjects using public method called display()defined in student class.11.Write a program that define two class one isPerson and another is main method class.Person class should have instance variableslike name, age and salary of type string, int andfloat. Use new operator to create a Personobject and call constructor to initialize theinstance variable and display its value.12.Write a program that creates two classes one isEmployee and another is main method class.Employee class contain emp_code, name,designation and salary fields, and threeconstructor one is default constructor, secondconstructor contain three filed emp code, nameand designation& if designation is clerk setsalary of Rs. 5000 if designation is peon setsalary of Rs. 2000 and if manager set salary ofRs. 10000 for others set salary of Rs. 1000 andthird constructor contain four fileds emp code,name, designation and salary. Displayinformation of employee using display method.

instance variableand instance

method.

5. 6 13.Create two class one is Family and second isrelative, Family class has data member likename,relation and dob, and Relative classinherit the properties of Family class and ithas data member like mobile no,address anddo the following operation. Create three constructor for base andderived class. Insert data through derived classparameterized constructor. Illustrate the use of this reference andSuper. Display all the information through parentclass reference variable.

14.Write a program to create three class; Vehicle,Twowheeler and Fourwheeler. In Vehicle classdata members are company name, and

Clear the conceptof inheritance,

constructor,super and superclass and derive

classconstructors.

Page 3: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 3

methods are input and display. Twowheelerinherit the properties of Vehical class and datamembers are name,type(gear,non gear) ; andmethods are input and display. FourWheelerclass inherit the properties of Vehical and it’sdata members are name, model no,fuel type;and methods are input and display. Useoverriding techniques for intput and displaymethods.15.Create two class one is Family and secondis relative, Family class has data memberlike name,relation and dob, and Relativeclass inherit the properties of Family classand it has data member like mobileno,address and do the following operation.a. Create three constructor for base andderived class.b. Insert data through derived classparameterized constructor.c. Illustrate the use of this referenceand Super.d. Display all the information throughparent class reference variable.

6. 2 16.There are three interface Bank,Private,andGovernment and one class Customer. Bankhave display method. Private interface inheritthe properties of Bank and it have datamembers like bank no, bank name, and totalallowing amount. Government interface inheritthe properties of Bank and it has datamembers like bank no,bank name and totalallowing amount. Customer inherit theproperties of Private and Governmentinterface and it has data member like accountno,name, sector(private or government),amount and total tax. Write a program whichwill accept information of customer and at thetime of insertion check whether the bank allowa customer to deposit inserted amount or not,if not then calculate tax of customer anddisplay it, create appropriate methods for allthe operations.17.Create a class called DataStructure withfollowing details.

Clear the conceptof interface and

package

Page 4: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 4

Data members:size, index, arrayElementsMethod:Constructor to set valuesDisplay method to display list ofelementsCreate one interface calledICollectionBehaviour, interface containsfollowing methods void add(intnumber)void delete()void display(int position)public void clear()create another class called Stack which isderived from DataStructure class andimplements ICollectionBehaviour interface.Method:Create a method to check whetherthe stack is empty or not, method shouldprivate.create another class called Queue which isderived from DataStructure class andimplements ICollectionBehaviour interface.Method:Create a method to check whetherthe Queue is empty or not, method shouldprivate.Create the objects of Stack and Queue classin Tester class and test them.

7. 3 18.Write a Java program which throws anexception whenever user enters a string of fivecharacters.19.Write a program to create custom exceptionfor bank that contain fields accountno, andbalance throw an exception for the followingcondition:

If withdrawing amount is greater thanactual amount. If balance become less than 500 afterwithdrawing amount.

Clear concept ofexceptions

Page 5: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 5

8. 2 20.Write a Java program which will insert datafrom the console and write into file.21.Write a Java program which will read datafrom the file and display on console.22.Write a Java program which will insert datafrom console and store it into file and counttotal no of character from the file.23.Write a Java program which will remove all thecomments from the file.

Clear the conceptof file handling.

___________________________________________________________________________________________________________Group - 2

Sr.No

AllocatedHours

List of Problems Objective

1. 3 1. Write a program to find out that the given nonumber is odd or even (pass argument incommand line argument)2. Write a program to find out the factorial ofgiven number (pass argument in command lineargument)3. Write a program to generate Fibonacci seriesusing FOR LOOP.4. Write a program to print following patternwith character ‘A’ passes as command lineargument for n row.A A A AA A AA AA

Clear basicconcepts of Java

platform,program

structure andcontrol

statements.

2. 2 5. Write a program that count total number ofcharacters in all of its command linearguments.6. Write a program that searches through itscommand line argument. If an argument thatdoes not begin with Upper case letter, displayan error message to user.7. Write a Java Program which will read a stringand rewrite it in the alphabetical order eg. Theword “STRING” should be written a “GINRST”.

Usage of Stringclass and

different function

3. 3 8. Write a program that read the elements of aone dimensional array and sort elements usingbubble sort.9. Write a program to find out that given numberis palindrome or not. (pass argument inncommand line argument ,and using array)

Concept of oneand two

dimension array.

Page 6: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 6

4. 6 10. Write a program that define class student, inwhich put field like student id,name,class nameand marks of minimum 5 subjects, and do thefollowing:1. Insert values for five students throughconstructor.2. Calculate percentage and grade, if studentis fail in any subject then grade is F and ifhe/she is pass then criteria for grade is asfollows:if per >=70 grade is A , if per >=60 and<70 then grade is B, and if per >=50 and<60 then grade is C, otherwise D.3. Display student information according tograde wise, whenever you display studentinformation.

11. Write a program to create classstring_operation in which data members arestr1 and str2 of string type and both are static,methods of a class are insert, comparison anddisplay; insert and comparison are staticmethod. After insertion of a two string; callcomparison method from insert method andafter checking whether the string is equal ornot display method will be called fromcomparison method for appropriate result.12. Write a program that define two class one isEmployee class and another is main methodclass; Employee class have data members likeemp_code,name,designation and salary; Insertat least five records of employee by creatingarray of object and display it using method.

Clear the conceptof class, object,

instance variableand instance

method.

5. 6 13. Create three class SocialNetwork, FaceBook,and Twitter; SocialNetwork class has datamember like username and password;FaceBook class inherit the properties ofSocialNetwork class and it has data memberlike scrap message and group name; Twitterclass inherit the properties of SocialNetworkand has data members like twit message andfollower and do the following operation. Insert data through derived classparameterized constructor. There are more than one user of FaceBookand Twitter so use appropriate technique

Clear the conceptof inheritance,

constructor,super and superclass and derive

classconstructors.

Page 7: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 7

for creating user. Illustrate the use of this reference. Create one reference variable ofSocialNetwork class and with the help of itdisplay information of Twitter. Write a method which will ask groupname and according to insertion displayall the users who are in that group.

14. Create two class one is Friend and anotheris Buddy, Friend class has data member likename and email-id, and Buddy class inheritthe properties of Friend class and it has datamember like dob,mobile no and address anddo the following operation. Create three constructor for base andderived class. Insert data through derived classparameterized constructor. Illustrate the use of this referenceand Super. Display all the information throughparent class reference variable.

15. Create three class Publisher,Book and Stock, Publisher class has data member likepublisher name and subject and email-id,and Book class inherit the properties ofPublisher class and it has data member likebook name,rate and Stock class inherit theproperties of Book class and it has datamember like total quantity and total rateand do the following operation.a. Create three constructor for base andderived class.b. Create array of object for Stock.c. Insert data through derived classparameterized constructor.d. Illustrate the use of this reference andSuper.e. Display all the information according topublisher wise and in proper formatthrough parent class reference variable.6. 2 16. Create one interface Student which have data Clear the concept

Page 8: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 8

member like student id and student name andmethod is display. Student_detail class inheritthe properties of Student and it has datamember like course. Display information of allthe students with the help of referencevariable of interface.17. Create a class called UserAccount.Data member:UserName, emailID, PassWord, DateOfBirth; keepprivate visibility.Method:Constructor, getter and setter methods.Create a interface called IMailBoxBehaviour,interface contain following method.void sendMessage(String receiverName, StringmessageTitle, String messageBody);void SaveMessage( String messageTitle, StringmessageBody);void AddContact(String contactName, StringemailID);void doChat(String friendName, String message);Create an interface called IMailBoxOptionsvoid forwardToOtherID(String emailID);void SMSAlert(String mobileNumber);Create another interface calledISocialNetworkBehaviour which is derivedfrom IMailBoxBehaviour interface. Interfacecontains following methods.void AddFriend(String friendName);void AddGroup(String groupName);void removerFriend(String friendName);create another class called Yahoo, which is derivefrom Account class and implementsIMailBoxBehaviour interface.Method:void createFolder(String folderName)create another class called Gmail, which is derivefrom Account class and implementsIMailBoxBehaviour and IMailBoxOptionsinterface.Method:

of interface andpackage

Page 9: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 9

void createLabel(String folderName)create another class called FaceBook, which isderived from Account class and implementsISocialNetworkBehaviour interface.Method:void post (String friendName,String message)create another class called Orkut, which is derivedfrom Account class and implementsISocialNetworkBehaviour interface.Method: void Scrap(String friendName,Stringmessage)Create a one tester class which test Yahoo, Gmail ,Facebook and Orkut class.7. 3 18. A method named average() has oneargument that is an array of Strings. Itconverts these to double values and returnstheir average. The method generates aNullPointerException if a array element isnull or NumberFormatException if anelement is incorrectly formatted. Write aprogram that illustrates how to declare anduse this method.

19. Write a program to create customexception for bank that contain fieldsaccountno, and balance throw an exceptionfor the following condition: If withdrawing amount is greater than10,000 amount than customer cannotwithdraw money. You need to check that whethercustomer’s balance does not cross theminimum balance value i.e 1000.

Clear concept ofexceptions

8. 2 20. Write a Java program which will insert datafrom console and store it into file and counttotal no of line from the file.21. Write a program which will remove allconsonants from the file and display it onconsole.22. Write a program which will read data fromone.txt file and copy into two.txt file.23. Write a program using 22nd program whichwill display data from two.txt in reverse

Clear the conceptof file handling.

Page 10: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 10

manner.___________________________________________________________________________________________________________Group - 3

Sr.

No

Allocated Hours

List of Problems Objective

1. 3 1. Write a program to input the radius of a circle and find itsarea, diameter and circumferences. (input of radius mustbe given from the keyboard)2. Write a program in which there are three variables whosedata type is byte, int and double; the value of int is 260and value of double is 323.142. Convert the value of intinto byte, double into int and double into byte and displayall the values after conversion.3. Write a program to print a following pattern (using nestedloop)15 14 13 12 1110 9 8 76 5 43 214. Write a program to print a following pattern (while loopwhere n = 4).value of n will be given by user.** ** * ** * * *

Clear basicconcepts of

Javaplatform,programstructure

and controlstatements.

2. 2 5. Write a Java Program which will read a string and rewriteit in the reverse order eg. The word “HELLO” should bewritten a “OLLEH”.6. Write a Java program that initialize a String object withyour first name and then prints it three times on sameline, separated by spaceE.g: String name=”Jhon”Output would be=John John John7. Write a program which accept one string and display allthe consonants from that string.

Usage ofString class

anddifferentfunction

3. 3 8. Write a program to display the multiplication of twodiagonals of the array of the two dimensional array.9. Write a program that identifies and remove duplicateelements in a one dimensional array. The program ask forthe size of the array, and after removing elements fromthe array display it on the screen.

Concept ofone and

twodimension

array.

Page 11: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 11

4. 6 10.Write a program that define two class ; one iscalculation_area which calculate different areas of shapeslike triangle,circle,square,rectangle,etc; using the conceptof method overloading and another is main method classin which create the object of calculation_area and usingthe concept of menu driven call different method ofcalculation_area.11.Write a program that defines two classes one isEmployee class and another is main method class;Employeeclass have data members like emp_code, name,designation and salary; Insert at least five records ofemployee by creating array of object and display it usingmethod.12.Write a program that create two class one is mainmethod class and another is to represent a bank accountthat includes the following member:

Data MembersOwner nameAccount numberBalance amount in the accountMethods MembersTo assign initial values.To deposit an amount.To withdraw an amount after checking balance minimumbalance must be Rs.500.To Display the owner name and balance.

Clear theconcept of

class,object,

instancevariable

andinstancemethod.

5. 6 13.Write a program to create 4 class, Person,Friends,Familyand main method class. In person class data members arename,city,nationality,emailid all are private and methodsare insert and display; in Friends class data members aredate-of –birth,address,contact no,group; all are publicand methods are insert, display and search; in Familyclass data members are date-of-birth,address,contactno,relation ; all are public and methods are insert,displayand search. Friends and Family class inherit properties ofPerson class. Create a menu driven program and optionsfor menu driven are insert,search,display and exit.Before performing any operation first ask user whetherthey want to perform operation on Friends or Family andaccording user choice perform operation which aregiven. Whenever user insert for search ask them whetherthey want to search by city or by name and according tothat display information. Create array of object forFriends and Family class.

Clear theconcept of

inheritance,constructor, super andsuper classand derive

classconstructor

s.

Page 12: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 12

14.Define four class Bank, Branch, Employee and mainmethod class. In Bank class data members are bank nameand its type (government or non-gov ) both are private.Branch class inherit Bank and it’s data members arebranch no and branch city and both are private.Employee class inherit Branch and its data members areemployee no, designation, salary. Write a program todisplay information of employee according to (1)designation wise, (2) branch wise (3) salary wise. Createdifferent method for all the operation.15.Define class Company,Product,Purchase and mainmethod class. In company class data member is companyname. Product class inherit Company and its datamembers are product name,qty,and rate ; methods isdisplay. Purchase class inherit product class datamembers are total quantity user want to purchase, andtotal amount. Write a program which ask user “whichproduct they want to purchase from given company andhow many quantity; according to user choice calculatetotal rate and display it. Check appropriate condition anduse constructor for insertion.

6. 2 16.There is one interface Gmail and two class Yahoo andFacebook. Gmail interface has data member likeusername and two methods create_account and display .Yahoo class has data member like user name and it hasmethod like create_user. Facebook class inherit theproperties of Gmail and Yahoo and it has data memberslike password and scrap and it has two method one forset password and another for scraping. Write a programwhich will create users and display information of usersaccording to account wise.h blocks in c() and d() containa throw statement to propagate this exception to theircaller. Use the println() method to monitor the flow ofcontrol in your program.17.Create a package called General.a. Create a one class in it called Person withappropriate properties and methods.Create 2nd package called StudentDetail.a. Create a class called Student which derivesfrom Person class with appropriate propertiesand method.b. Create a class called Exam with its additionalproperties and methods which is derived from

Student class.Create 3rd package called FacultyDetail.

Clear theconcept ofinterface

andpackage

Page 13: 060010301 – Java Programmingutu.ac.in/dcst/download/documents/PRMSCIT060010301.pdf · 060010301 Java Programming 2013 Ms. Anuja Vaidya Page 1 060010301-Java Programming Problem

060010301 – Java Programming 2013

Ms. Anuja Vaidya Page 13

a. Create a class called Faculty which derivesfrom Person class with appropriate propertiesand method.Create 4th package called Test. Make a driver class totest Exam and Faculty class by creating the objects ofthem.7. 3 18.Write a program to do division of two numberHint: Input should be from command line.Handle ArithmeticException,ArrayIndexOutofBoundsException,NumberFormatException

19.Write a program to do division of two numbers.Hint: Make function called doDivision() to do divisionof two numbers. During the division process if runtime error may occur throw error to calling function.Handle ArithmeticException,ArrayIndexOutofBoundsException,NumberFormatException in main() method only.

Clearconcept

exceptions

8. 2 20.Write a program which will insert data from the consol inreverse manner and write into file.21.Using 20th program display the file data in reverse orderon console.22.Write a program which will remove all vowels from thefile and display it on console.23.Write a Java program which will insert data from consoleand store it into file and count total no of word from thefile.

Clear theconcept of

filehandling.