Week 5 Solution

$30.00 $24.00

Objective: Implementing the concepts of class variable, instance variable, use of “this” keyword, use of reference variable in Java. Assignments: Create a “circle” class & a “point” class. The coordinates of the circle are given and used within the “circle” class as object of the “point” class. Display the area of circle. Create a class…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

Objective: Implementing the concepts of class variable, instance variable, use of “this” keyword, use of reference variable in Java.

Assignments:

  1. Create a “circle” class & a “point” class. The coordinates of the circle are given and used within the “circle” class as object of the “point” class. Display the area of circle.

  1. Create a class called Time, which has three private instance variables – hour, min and sec. It contains a method called add( ) which takes one Time object as parameter and print the added value of the calling Time object and passes Time object. In the main method, declare two Time objects and assign values using constructor and call the add() method.

  1. Create a class called Complex, which has three private instance variables –real and imaginary. It contains a method called add( ) which takes one Complex object as parameter and print the added value of the calling Complex object and passes Complex object. In the main method, declare two Complex objects and assign values using constructor and call the add() method.

  1. Write a program to define a class having one 3-digit number, num as data member. Initialize and display reverse of that number.

  1. Write a program to define a class Student with four data members such as name, roll no., sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

  1. Write a program to define a class Employee to accept emp_id, emp _name, basic_salary from the user and display the gross_salary.

  1. Write a program to define a class Fraction having data members numerator and denominator. Initialize three objects using different constructors and display its fractional value.

  1. Write a program to define a class Item containing code and price. Accept this data for five objects using array of objects. Display code, price in tabular form and also, display total price of all items.

  1. Write a program to define a class Tender containing data members cost and company name. Accept data for five objects and display company name for which cost is minimum.

  1. Write a program to define a class ’employee’ with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

  1. Define a class called circle that contains:

    • Two private instance variables: radius (of type double) and color (of type String),

    • Initialize the variables radius and color with default value of 1.0 and “red”, respectively using default constructor.

    • Include a second constructor that will use the default value for color and sets the radius to the value passed as parameter.

    • Two public methods: getRadius() and getArea() for returning the radius and area of

the circle

    • Invoke the above methods and constructors in the main.

  1. Write a program which will accept an integer from the user and pass the value to a method called PrintNumberInWord that will print “ONE”, “TWO”,… , “NINE”, “ZERO” if the integer variable “number” is 1, 2,… , 9, or 0, respectively.

  1. Design a class named Account that contains:

I.A private int data field named id for the account (default 0).

  1. A private double data field named balance for the account (default 0).

  1. A private double data field named annualInterestRate that stores the cur-rent interest rate (default 0). Assume all accounts have the same interest rate.

IV. A private Date data field named dateCreated that stores the date when the

account was created.

  1. A no-arg constructor that creates a default account.

VI.

A constructor that creates an account with the specified id and initial balance.

VII.

The accessor and mutator methods for id,balance, and annualInterestRate.

VIII.

The accessor method for dateCreated.

IX.

A method named getMonthlyInterestRate() that returns the monthly interest rate.

  1. A method named getMonthlyInterest() that returns the monthly interest.

XI. A method named withdraw that withdraws a specified amount from the account.

XII. A method named deposit that deposits a specified amount to the account.

  1. Write a test program that prompts the user to enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%), and print a table that displays future value for the years from 1 to 30, as shown below:

The amount invested: 1000

  1. 1093.8

  1. 1196.41

  1. 13467.25

  1. 14730.57

  1. Write method headers for the following methods:

a. Computing a sales commission, given the sales amount and the commission rate.

      1. Printing the calendar for a month, given the month and year.

      1. Computing a square root.

      1. Testing whether a number is even, and returning true if it is.

      1. Printing a message a specified number of times.

f. Computing the monthly payment, given the loan amount, number of years, and annual interest rate.

  1. Write a program that reads ten numbers, computes their average, and finds out how many numbers are above the average. [Use this keyword]

  1. Write a program that reads ten integers and displays them in the reverse of the order in which they were read.

  1. Write a program to demonstrate use of ‘this’ keyword.

  1. Write a program to demonstrate use of ‘static’ keyword.

  1. Write a program to accept value of apple sales for each day of the week (using array of type float) and then, calculate the average sale of the week.

  1. Write program, which finds the sum of numbers formed by consecutive digits. Input : 2415

output : 24+41+15=80.

  1. Write a Java Program to Solve Producer Consumer Problem Using Synchronization.

  1. Write a Java Program to Show that Method Will be Verified Whether it is Synchronized or Not.

  1. Write a Java Program to Show How Can Class Object be Locked Using Method Level Synchronization.

  1. Write a Java Program to Synchronize the Threads Acting on the Same Object. The Synchronized Block in the Program can be Executed by Only One Thread at a Time.

  1. Write a Java Program to Avoid Dead Locks.

  1. Write a Java Program to Solve Deadlock Using Thread.

  1. Write a Java Program to Create a Thread that Implement the Runnable Interface.

  1. Write a Java Program to Show the Priority in Threads.

  1. Write a Java Program to Check Priority Level of a Thread.

  1. Write a Java Program to Set the Priority of a Thread.

  1. Write a Java Program to Get the Priorities of Running Threads.

  1. Write a Java Program to Access the Priority You Can Use Method With Thread Object.

  1. Write a Java Program to Use Join Thread.

  1. Write a Java Program Defining Thread By Extending Thread.

  1. Write a Java Program to Handle IllegalThreadStateException.

  1. Write a Java Program to Check Whether Static Block will be Used.

  1. Write a Java Program to Show Why Exit Method is Used in Static Method.

  1. Write a Java Program to Illustrate Thread Example for setName(string name).

  1. Write a Java Program to Illustrate Thread Example for Destroy().

  1. Write a Java Program to Illustrate Thread Example for suspend().

  1. Write a Java Program to Illustrate Thread Example for currentThread().

  1. Write a Java Program to Illustrate Thread Example for run().

  1. Write a Java Program to Illustrate Thread Example for getThreadGroup().

  1. Write a Java Program to Illustrate Thread Example for getPriority().

  1. Write a Java Program to Illustrate Thread Example for Alive().

  1. Write a Java Program to Illustrate Thread Example for getName().

  1. Write a Java Program to Show Interfaces Can be Extended.

  1. Write a Java Program to Check a Thread is Alive or Not.

  1. Write a Java Program to Get the Name of a Running Thread.

  1. Write a Java Program to Get the Name of the Thread.

  1. Write a Java Program to Check if a Given run() Method is Overloaded in the Thread Class.

  1. Write a Java Program to Check Whether Define a Thread Class Without Defining run() Method in the Class.

  1. Write a Java Program to Stop a Thread.

  1. Write a Java Program to Suspend a Thread for a While.

  1. Write a Java Program to Check a Thread has Stopped or Not.

Week 10

Objective: Implement the concepts of Applets in Java.

Assignments:

  1. Design a Java applet that will blink “Hello Applet” message in the client area and play a musical sound in the background with a background picture in client area.

  1. Design an applet that will display a text as scrolling marquee. The text can be changed by setting different “PARAMS” value.

  1. Design a Java applet that displays various shapes like circle, rectangle etc.

  1. Design an applet to create digital clock using thread. The clock shows system hh:mm:ss and date.

  1. Write a applet to draw the following shapes:

    • Rectangle with rounded corner

    • Square inside a circle.

  1. Write a Java Program to Create Two Lables and Two Text Fields for Entering Name and Passwords. The Password Typed by the User in the Text Field is Hidden.

  1. Write a Java Program to Display Text in the Frame by Overriding PaintComponent() Method of JPanel Class.

  1. Write a Java Program to Display Some Text in the Frame with the Help of a Label.

  1. Write a Java Program to Create a Text Area and Display the Mouse Event When the Button on the Mouse is Clicked, When the Mouse is Moved etc is Done by the User.

  1. Write a Java Program to Create a Banner Using Applet.

  1. Write a Java Program to Display Clock Using Applet.

  1. Write a Java Program to Create Different Shapes Using Applet.

  1. Write a Java Program to Fill Colors in Shapes Using Applet.

  1. Write a Java Program to go to a Link using Applet.

  1. Write a Java Program to Create an Event Listener in Applet.

  1. Write a Java Program to Display Image Using Applet.

*************************************************

Week 5 Solution
$30.00 $24.00