ALIGARH MUSLIM UNIVERSITY Department of Computer Science. JAVA Lab Assignment Course: MCA II nd Semester Academic Session:

Similar documents
Write a java program to prints the count of odd and even no s entered.

PROGRAMMING IN C AND C++:

Laboratory Manual. Laboratory Course II (CSM 22P1) M.C.A. II Semester. Department of Computer Science. Aligarh Muslim University Aligarh

Object Oriented Programming 2012

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Ascending. Load. Descending. Save. Exit. Numbers

CSE 212 : JAVA PROGRAMMING LAB. IV Sem BE (CS&E) (2013) DEPT OF COMPUTER SCIENCE & ENGG. M. I. T., MANIPAL. Prepared By : Approved by :

Object Oriented Programming Using C ++ Page No. : 1. ASSIGNMENT SHEET WITHOUT USING OBJECT AND CLASSES

UNIVERSITY OF ENGINEERING & MANAGEMENT, KOLKATA C ASSIGNMENTS

College Readiness (597 topics) Course Name: College Prep Math Spring 2014 Course Code: ARTD4-3N6XJ

Lab ACN : C++ Programming Exercises

B. V. Patel Institute of Business Management, Computer & Information Technology, UTU 2013

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

TIME: 3 HOURS MARKS: a. Develop a java program to sort an array of N numbers in ascending order. (40)

Lab Manual Object Oriented Programming with JAVA (15ECSP203)

Suggestive List of C++ Programs

22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.

3D Graphics Programming Mira Costa High School - Class Syllabus,

Integer Operations. Summer Packet 7 th into 8 th grade 1. Name = = = = = 6.

VALLIAMMAI ENGINEERING COLLEGE

Subject: Computer Science

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

Stratford upon Avon School Mathematics Homework Booklet

Practical List of. MCA IV SEM Session -2010

DEPARTMENT OF INFORMATION TECHNOLOGY

Final Java Experiment List(For Internal and External)

PROGRAMS. EXCELLENT ACADEMY OF ENGINEERING. Telephone: / NORMAL PROGRAM

LIST OF EXPERIMENTS. (1) (Office Automation)

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

Shapes leading to CAD system project

PDS Lab (Assignment 1) Date: 31 st July, 2017 (2-6 pm)

Use the scantron sheet to enter the answer to questions (pages 1-6)

AP CSA 3rd Period MR. D. Course Map

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Hegarty Maths Clip Numbers List

Objective 1 : The student will demonstrate an understanding of numbers, operations, and quantitative reasoning.

Middle School Math Course 3

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK

END TERM EXAMINATION

Chapter 3 Problem Solving and the Computer

Condition Controlled Loops. Introduction to Programming - Python

WEST VIRGINIA ADULT BASIC EDUCATION SKILLS CHECKLIST ABE MATHEMATICS Federal Functioning Level 1 Beginning Literacy (0 1.9)

DEPARTMENT OF ACADEMIC UPGRADING

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.

Grade 7 Unit 1 at a Glance: Working With Rational Numbers

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE1303. B.Tech. Year - II

Downloaded from

Mathematics - LV 6 Correlation of the ALEKS course Mathematics MS/LV 6 to the Massachusetts Curriculum Framework Learning Standards for Grade 5-6

Middle School Math Course 2

Montana City School GRADE 5

Middle School Math Course 3 Correlation of the ALEKS course Middle School Math 3 to the Illinois Assessment Framework for Grade 8

Computer Science & Engineering. Second Year

NMC Sample Problems: Grade 8

Summary Of Topics covered in Year 7. Topic All pupils should Most pupils should Some pupils should Learn formal methods for

The Hyderabad Public School, Begumpet, Hyderabad, A.P

3rd Grade Mathematics

DEPARTMENT OF ACADEMIC UPGRADING

CONDITION CONTROLLED LOOPS. Introduction to Programming - Python

2009 Fall Startup Event Thursday, September 24th, 2009

PRACTICE EXAM CREATORS

Babu Madhav Institute of Information Technology 2016

Mathematics LV 5 (with QuickTables)

Performance Level Descriptors. Mathematics

Maths Key Stage 3 Scheme of Work Number and measures Place value Calculations Calculator Measures

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Essential Mathematics (with QuickTables)

Florida Math 0018 Correlation of the ALEKS course Florida Math 0018 to the Florida Mathematics Competencies - Lower

IS502052: Enterprise Systems Development Concepts Lab 1: Java Review

Introduction to Computer Science with Python Course Syllabus

Course Outline. Introduction to java

Year Nine Scheme of Work. Overview

Grade 4 CCSS Pacing Guide: Math Expressions

DEPARTMENT OF ACADEMIC UPGRADING

Smarter Balanced Vocabulary (from the SBAC test/item specifications)

Mathematics Curriculum

1. One-third of 105 is the same as seven-sixths of what number? 1.

Academic Vocabulary CONTENT BUILDER FOR THE PLC MATH GRADE 1

Final Exam Review (Revised 3/16) Math MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

CP I LAB MANUAL. Expt No 2 To Check Whether A Year Is A Leap Year Using if-else-if.

PRACTICAL LIST FOR ODD SEMESTERS Session (PGDCA/MCA/MSC (CS))

P>80 A P>70 && P<80 B P<70 C 12. Calculate employee salary according to following condition

Math 7 Glossary Terms

R. C. TECHNICAL INSTITUTE, AHMEDABAD COMPUTER ENGG. DEPARTMENT ASSIGNMENT 1

Extended Mathematics for Cambridge IGCSE by David Rayner. Chapter 1. Identify and use rational and irrational numbers, real numbers.

FOURTH GRADE Mathematics Standards for the Archdiocese of Detroit

CMSC 132: Object-Oriented Programming II. Inheritance

Inheritance, Polymorphism, and Interfaces

Algorithms 4. Odd or even Algorithm 5. Greatest among three numbers Algorithm 6. Simple Calculator Algorithm

Content Skills Assessments Lessons

Common Core Math Curriculum Map

6th Grade Arithmetic (with QuickTables)

Rani Durgavati Vishwavidyalaya Jabalpur (M.P.) (UICSA) Master of Computer Application (MCA) Practical List of. MCA III SEM Session -2010

Syllabus of Diploma Engineering. Computer Engineering. Semester: II. Subject Name: Computer Programming. Subject Code: 09CE1104

RtI 7. Curriculum (219 topics additional topics)

Connecticut Alternate Assessment: Individual Student Report Performance Literals Mathematics

Mathematics - LV 6 Correlation of the ALEKS course Mathematics MS/LV 6 to the State of Texas Assessments of Academic Readiness (STAAR) for Grade 6

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

Gain familiarity with factors and multiples. Use place value understanding and properties of operations to perform multi-digit arithmetic.

Transcription:

ALIGARH MUSLIM UNIVERSITY Department of Computer Science Dated: 25-01-2016 JAVA Lab Assignment Course: MCA II nd Semester Academic Session: 2015-2016 CSM-241: Object Oriented Programming Using JAVA Note: You must work individually. Copying assignment will result zero grade for all the students involved. Late Submission will not be accepted Dates of Viva and final Submission as follows :- Final Submission : 25/04/2016 Viva of Group I : 27/04/2016 Viva of Group II : 30/04/2016 Problem #1: Write a Java program to calculate sum of two numbers. Problem #2: Write a java program to prints the count of odd and even no s entered. Problem #3: Write a program to convert the given temperature in Fahrenheit to Celsius using the following conversion formula C = F-32 / 1.8 and display the value in a tabular form. Problem #4: Write Java program to print the squares and cubes for the numbers 1 to 5. Problem #5: Write a java program to find the roots of a quadratic equation. Assign the values of a, b and c of the equations in the program itself. Problem #6: Write a java program for finding the sum, difference, product, quotient, minimum and maximum of any two integers. Problem #7: Write a java program 'MyNumber.java" that performs following operations on a variable 'num' of type double: a) Finds the round value of 'num' and stores the result in a variable numround of type double. b) Finds the ceil value of 'num' and stores the result in a variable numceil of type double. c) Finds the floor value of 'num' and stores the result in a variable numfloor of type double d) Cast 'num' to type int and stores the result in a variable numinteger of type int.

Display output of numround, numceil, numfloor and numinteger on screen. Note: Test your program with following value of num num=56.764 num=36.432 Use Math.round, Math.ceil, Math.floor methods of class Math for 1,2 and 3. Problem #8: Write Java program to show uses of all Math class methods. Problem #9: Write Java program to compute the sum of the 2+4+6+ ---------+10. Problem #10: Write a java program that computes the sum of the reciprocals: 1/1 + 1/2 + 1/3 +... + 1/10 Problem #11: Shown below is a Floyd s triangle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (a). Write a program to print this triangle. (b). Modify the program to produce the following form of Floyd s triangle. 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 Problem #12: Write a program in the sequence 1 1 2 3 5 8 13 21 is called Fibonacci numbers. Write a program using a do while loop to calculate and print the first m Fabonacci numbers. Problem #13: Write a program to accept three digits (i.e. 0-9) and print all its possible combinations. (For example if the three digits are 1, 2, 3 than all possible combinations are: 123, 132,213, 231, 312, 321.) Problem #14: Write a program to calculate the area of triangle, square, circle, rectangle by using method overloading.

Problem #15: Write a Java Program which prompts the user to enter 4 numbers. The program will then computes and display their sum and their product. Problem #16: Write a Java program which reads a 4-digit number and prints the digits on separate lines. (Each digit is printed on one line). Problem #17: The intersection method computes the intersection of two rectangles- that is, the rectangle that is formed by two overlapping rectangles: You call this method as follows: Rectangle r3 =r1.intersection(r2); Write a program that constructs two rectangle objects, prints them, and then prints their intersection. What happens when the rectangles do not overlap? Problem #18: Write Java program involving two classes: OddAndEven and TestOddAndEven. OddAndEven has the following: Instance varaibales countofodd and countofeven both of type int A method addnumber that takes a number as parameter and increment countofodd, if the number is odd, else increment countofeven. A method tostring that returns a string in the form: Number of Odd: x, Number of Even : y, where x and y are the values of the instance variables. The TestOddAndEven class first creates OddAndEven object, then in a loop, read a number and use it to call the addnumber method until the user enters Q. Finally, it prints the count of odd and even numbers entered. Output of your program must be in the following format: Problem #19: In a small firm employee numbers are given in serial numerical order, that is 1, 2, 3 etc. write a menu driven program to perform following operations: a) Create a file of employee data with following information: Employee No, Name, Sex, Gross Salary. b) Append the data of a new employee joining the firm. c) If a given employee leaves, delete his record. d) If gross salary of a given employee increases, update the gross salary. e) Display the record of (i) a given employee or (ii) all employees.

Problem #20: Design a class Circle and implement the following methods: Define a circle method to compute its area Define a circle method to compute its perimeter Define a method that takes a given point represented by a pair of numbers and checks whether or not the point is inside the circle. The circle class needs to have instance variables to store the radius of the circle, and the x and y coordinates of the center. Add main program to test the class Circle repeatedly, until user enters negative value for the radius of the circle. Problem #21: The certain instructor assigns letter grade for his course based on the following table: Score Grade >= 90 A+ >= 85 A >= 80 B+ >= 75 B >= 65 C+ >= 60 C >= 55 D+ >= 50 D < 50 F figure (b) Write a class, Grader, which has an instance variable, score, an appropriate constructor and appropriate methods a method, lettergrade() that returns the letter grade as a String. Now write a demo class to test the Grader class by reading a score from the user, using it to create a Grader object after validating that the value is not negative and is not greater then 100. Finally, call the lettergrade() method to get and print the grade. See figure (b) for sample run. Problem #22: A sales person is paid commission based on the sales he makes as shown by the following table: SALES COMMISSION Under 2 % of SALES SR500 SR500 5 % of SALES and under SR5000 figure (a) SR5000 8 % of SALES and over Write a class, Commission, which has an instance variable, sales; an appropriate

constructor; and a method, commission() that returns the commission. Now write a demo class to test the Commission class by reading a sale from the user, using it to create a Commission object after validating that the value is not negative. Finally, call the commission() method to get and print the commission. If the sales are negative, your demo should print the message Invalid Input. See figure (a) for sample run. Problem #23: Create a package called "Arithmetic" that contains methods to deal all arithmetic operations. Also, write a program to use the package. Problem #24: Write a program to make use of a parameterized method inside a class. Take the following case: Create a class Box and define a method in this class which will return the volume of the box. Initialize two objects for your class and print out the volumes respectively. Problem #25: Write a program to read a line of text from keyboard then using StringTokenizer class print each word of this text in separate line (one word per line) and at the last print total number of words in the text. Problem #26: Write a program that prompts for and read e-mail address of a user. The program then prints the user name and the domain name on different lines using StringTokenizer class. Problem #27: Write a program in Java that reads in text and prints as output the following: The number of words in the text The number of sentences in the text The number of times the letter e occurs in the text The number of times the letter z occurs in the text ( Note: Use StringTokenizer class )

Problem#28: Implement a Student class with the following fields, constructors and methods : Fields: name; totalscore; numberofquizzes; Constructors: public Student(String name, double score) public Student(double score, String name) public Student(String name) { Methods: public String getname() public double getaverage() //this should return zero if no quiz has been taken. public double gettotalscore() public void addquiz(double score) public void printstudent() //this should print the student s name and average score public String tostring() Write an application TestStudent that reads a student name and use the Student class to create a Student object. Then read the scores of the student in three quizzes and add each to the totalscore of the student using addquiz() method and print the student object. ( Note: Make use of this key word wherever it can be used ). Problem #29: Write a program to design a class to represent a bank account. Include the following members. Date members Name of depositor Account Number Type of account Balance account in the account Methods:- To assign initial values To deposit an account To withdraw an account after checking balance. To display the name and balance

Problem #30: Write a program that reads in a sentence from the user and prints it out with each word reversed, but with the words and punctuation in the original order: Problem #31: Implement a superclass Person. Make two classes, Student and Instructor, inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary. Write the class definitions, the constructors, and the methods tostring for all classes. Supply a test program that tests these classes and methods. Problem #32: Write a program where interface can be used to support multiple inheritances. Develop a standalone Java program for this. Problem #33: Implement the classes for the shapes using an interface for the common methods, rather than inheritance from the superclass, while still Shape as a base class. Problem #34: Write a program that calls a method that throws an exception of type ArithmeticExcepton at a random iteration in a for loop. Catch the exception in the method and pass the iteration count when the exception occurred to the calling method by using an object of an exception class you define. Problem #35: Write a program that will count the number of character in a file Problem #36: Write a program to create a sequential file that could store details about five products. Details include product code, cost, and number of items available and are provided through the keyboard. Problem #37: Write a Java program which reads student grades from a text file called grades.txt and prints only the corresponding letter grades into a file called letter.txt. The letter grades are assigned according to the following table. Assume that the grades.txt file can have any number of students grades. Hint: The last number in the grades.txt file is -1 Score Grade >= 90 A+ >= 85 >= 80 A B+ >= 75 B >= 65 C+ >= 60 C

>= 55 D+ >= 50 D < 50 F Problem #38: Write a program to read a,b,c from data file and store roots of the quadratic equation in output file. You must open your output file in append mode. Problem #39: Develop an applet that receives three numeric values as input from the user and then displays the largest of the three on the screen. Write a HTML pages and test the applet. Problem #40: Write applets to draw the following shapes: a). Cone c). Square inside a circle b).cylinder d). Circle inside square Problem #41: Write an applet that will display the following on a green background. Use the following dimension: Rectangle: (10, 10, 300, 150), fill color: blue Left circle: (10, 10, 150, 150), fill color: yellow Right circle: (159, 10, 150, 150), fill color: yellow Text: (110, 90), color: red Sample Output: Problem #42: Write a java Applet program to plot the following face:

Problem #43: Write a graphics program that draws a clock face with a time that the user enters in a text field. (The user must enter the time in the format hh:mm, for example 09:45. ). Hint: You need to find out the angles of the hour hand and the minute hand. The angle of the hour hand is harder; it travels 360 degree in 12 x 60 minutes. Your output must be in the following format: Problem #44: Write a program that draws the picture of a house. Sample Output:

Problem #45: Define a class Employee having private members id, name, department, salary. Define default and parameterized constructors. Create a subclass called Manager with private member bonus. Define methods accept and display in both the classes. Create n objects of the Manager class and display the details of the manager having the maximum total salary (salary+bonus) Problem #46: Write a Java program to create a super class Vehicle having members Company and price. Derive 2 different classes LightMotorVehicle (members mileage) and HeavyMotorVehicle (members capacity-in-tons). Accept the information for n vehicles and display the information in appropriate form. While taking data, ask the user about the type of vehicle first. Problem #47: A bank maintains two kinds of accounts - Savings Account and Current Account.The savings account provides compound interest, deposit and withdrawal facilities. The current account only provides deposit and withdrawal facilities. Current account holders should also maintain a minimum balance. If balance falls below this level, a service charge is imposed. Create a class Account that stores customer name, account number, and type of account. From this derive the classes Curr-acct and Sav-acct. Include the necessary methods in order to achieve the following tasks. a. Accept deposit from a customer and update the balance. b. Display the balance. c. Compute interest and add to balance. d. Permit withdrawal and update the balance (Check for the minimum balance, impose penalty if necessary). Problem #48: Define a class called fruit with the following attributes: 1. Name of the fruit. 2. Single fruit or bunch fruit. 3. Price. Define a suitable constructor and displayfruit() method that displays values of all the attributes. Write a program that creates 2 objects of fruit class and display their attributes. Problem #49: Write an applet to display the following figure:

Problem #50: Draw a bull s eye a set of concentric rings in alternation black and white colors: Fill a black circle, and then fill a smaller white circle on top, and so on. Problem #51: Write a program that reads in three strings and sorts them lexicographically. Enter strings: Charlie Able Banker Output: Able Banker Charlie