1.
Write
an application that calculates and displays the weekly salary of an employee.
In the main() method, prompt the user to enter the hourly_pay_rate, regular_working_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.
2. When gasoline is Rs 120 per barrel, then the consumer’s price at the pump is
between Rs 3.60 and Rs 4.20 per gallon.
Create a class named GasPrice such that its main()
method holds an integer variable named price_per_barrel to which you will assign
a value entered by a user at run time.
Create a method to which you pass
price_per_barrel. The method displays the range of possible prices per gallon.
For example, if gas is Rs150 per barrel, then the price at the pump should be
between Rs 4.50 and Rs 5.25.
3. Create a class named
TestBankAccount whose main() method declares 3 BankAccount objects.
Call a
getData() method 2 times. Within the method, prompt the user to enter 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 3rd 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 i.e. if the balance is less than Rs 1000 then Rs 100 will be deducted.
4.
Create a class named Billing that includes three overloaded computeBill() methods
for a photo book store.
When computeBill()
receives a single parameter, it represents the price of one photo book ordered.
Add 7.5% tax, and return the total due.
When computeBill()
receives two parameters, they represent the price of a photo book and the
quantity ordered. Multiply the two values, add 7.5% tax, and return the total
due.
When computeBill()
receives three parameters, they represent the price of a photo book, the
quantity ordered, and a coupon value. Multiply the quantity and price, reduce
the result by the coupon value, and then add 7.5% tax and return the total due.
Write a main() method that tests all three overloaded methods.
5.
Create a class named State that holds the appropriate fields for
name of the state, an population, and two City objects that
hold data about the capital city and the most populour city.
The State
constructor requires parameters that represent the names and populations of
the state, its capital, and its most populour city. Provide get methods for
each field.
Create the City class
to be a non-static, private inner class within the State class; the City class
contains a city’s name and population. Create a class to assign values to and
display values from two State objects.
Hi, Thanks for this valuable information sharing with us. This is very useful for me and many others people. Keep update Thanks once again.
ReplyDeleteJava Training in Noida
good questions
ReplyDeleteGood Post! Thank you so much for sharing the post, it was so good to read and useful to improve
ReplyDeleteJava Training in Electronic City
Well, that is the nice post for java programming. If somehow interested to know about Hindu temples of India visit here at https://www.astrolika.com/temples/.
ReplyDelete