Вы находитесь на странице: 1из 2

Exercise

1. Write an application to report time available in minutes & seconds if total no. of
seconds (e.g: 500) are given.

2. Write an application to find average of “n” elements of array and find out the count
regarding how many element are above average.

3. Write a program to create an array of float-type and size "n" (where "n" is taken as input
from user). Perform the following tasks on this array:
a) finding average of all elements and printing how many elements in array are above
average.
b) type-convert all elements of array into short-type and insert them in new array and
display the resulting array.

4. Write an application to implement different objects of following Circle class:

5. Write an application to create TV class having following features that work if TV is on:
6. Write an application that calculates and displays the weekly salary for an employee.
The main() method prompts the user for an hourly pay rate, regular hours, and
overtime hours. Create a separate method to calculate overtime pay, which is regular
hours times the pay rate plus overtime hours times 1.5 times the pay rate; return the
result to the main() method to be displayed. Save the program as Salary.java.

7. When gasoline is $100 per barrel, then the consumer’s price at the pump is between
$3.50 and $4.00 per gallon. Create a class named GasPrices. Its main() method holds
an integer variable named pricePerBarrel to which you will assign a value entered by
a user at the keyboard. Create a method to which you pass pricePerBarrel. The method
displays the range of possible prices per gallon. For example, if gas is $120 per barrel,
then the price at the pump should be between $4.20 and $4.80. Save the application
as GasPrices.java.

8. Create a class named TestBankAccount whose main() method declares four


BankAccount objects. Call a getData() method three times. Within the method,
prompt a user for values for each field for a BankAccount, and return a BankAccount
object to the main() method where it is assigned to one of main()’s BankAccount
objects. Do not prompt the user for values for the fourth BankAccount object, but let
it continue to hold the default values. Then, in main(), pass each BankAccount object
in turn to a showValues() method that displays the data, calls the method that deducts
the monthly fee, and displays the balance again. The showValues() method also calls
the method that explains the deduction policy. Save the application as
TestBankAccount.java.

Вам также может понравиться