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

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

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

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

Object Oriented Programming 2012

Ascending. Load. Descending. Save. Exit. Numbers

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

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

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

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

VALLIAMMAI ENGINEERING COLLEGE

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.

Subject: Computer Science

DEPARTMENT OF INFORMATION TECHNOLOGY

Practical List of. MCA IV SEM Session -2010

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

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

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

Final Java Experiment List(For Internal and External)

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

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

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

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

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

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

AP CSA 3rd Period MR. D. Course Map

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

2009 Fall Startup Event Thursday, September 24th, 2009

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.

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

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

Downloaded from

Middle School Math Course 2

Montana City School GRADE 5

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

NMC Sample Problems: Grade 8

UNIVERSITY OF MUMBAI T.Y.B.Sc.( INFORMATION TECHNOLOGY) (Semester V) (Practical) EXAMINATION OCTOBER ASP.NET with C# Seat No. : Max.

FOURTH GRADE Mathematics Standards for the Archdiocese of Detroit

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

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

DEPARTMENT OF ACADEMIC UPGRADING

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

Computer Science & Engineering. Second Year

CONDITION CONTROLLED LOOPS. Introduction to Programming - Python

Time: 3 HOURS Maximum Marks: 100

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

Get Unique study materials from

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.

Angles and Polygons. Angles around a point, on a straight line and opposite angles. Angles in parallel lines (alt, corr and co-int angles)

Math 7 Glossary Terms

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

5th Grade Mathematics Essential Standards

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

CMSC 132: Object-Oriented Programming II. Inheritance

Archdiocese of Washington Catholic Schools Academic Standards Mathematics

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

CHOICE BASED CREDIT SYSTEM (With effect from )

Transcription:

Dated: 27-01-2014 ALIGARH MUSLIM UNIVERSITY Department of Computer Science CS-2P1: Object Oriented Programming Using JAVA Java Lab Assignment Course: MCA (Semester-II nd ) Academic Session: 2013-2014 Note: You must work individually. Copying assignment will result zero grade for all the students involved. Late Submission will not be accepted Date of Viva and final Submission as follows :- (Group-I st : Roll no- 01-35) :- 19-04-2014 (Group-II nd : Roll no- 36-65, 2012-51):- 21-04-2014 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: 1

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 2

(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 and 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: 3

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. 4

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: 5

SALES Under SR500 SR500 and under SR5000 SR5000 and over COMMISSION 2 % of SALES 5 % of SALES 8 % of SALES figure (a) 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. 6

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#: 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() 7

score public void addquiz(double score) public void printstudent() //this should print the student s name and average 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 #28: 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 #29: 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: 8

Problem #30: 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 #31: Write a program where interface can be used to support multiple inheritances. Develop a standalone Java program for the example. Problem #32: 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 #33: 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 #34: Write a program that will count the number of character in a file Problem #35: 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 #36: 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 A >= 80 B+ >= 75 B >= 65 C+ >= 60 C 9

>= 55 D+ >= 50 D < 50 F Problem #37: 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 #38: 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 #39: Write applets to draw the following shapes: a). Cone c). Square inside a circle b).cylinder d). Circle inside square Problem #40: 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: 10

Problem #41: Write a java Applet program to plot the following face: Problem #42: 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: 11

Problem #43: Write a program that draws the picture of a house. Sample Output: Problem #44: 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) 12

Problem #45: 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 #46: 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 #47:.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 #48: Write an applet to display the following figure: Problem #49: 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. 13

Problem #50: Write a program that reads in three strings and sorts them lexicographically. Enter strings: Charlie Able Banker Output: Able Banker Charlie 14