Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need a short simple java code :) 1. Exercise: Invoice class Create a class called Invoice that a hardware store might use to represent

i need a short simple java code :)
image text in transcribed
1. Exercise: Invoice class Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An invoice should include four pieces of information as instance variables-a part number (type String), a part description(type String), quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getinvoice Amount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0 . If the price per item is not positive, it should be set to 0.0. Write a test application named InvoiceTest that demonstrates class Invoice's capabilities. I1. Exercise: Date class Create a class called Date that includes three pieces of information as instance variables-a month (type int), a day (type int) and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes[/]. Write a test application named DateTest that demonstrates classDate's capabilities. Umm A.Qura university Computer & information Systems college Instructoe: Dr. Avmen M, Alerenil III. Exercise : SavingAccount Create class SavingsAccount. Usea static variable annualinterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has ondeposit. Provide method calculateMonthlylnterest to calculate the monthly www.oumstudents.tk interest by multiplying the savingsBalance by annualinterestRate divided by 12 this interest should be added to savingsBalance. Provide a static method modifylnterestRate that sets the annualinterestRate to a new value. Write a program to test class S avingsAccount. Instantiate two savingsAccount objects, saver 1 and saver 2 , with balances of $2000.00 and $3000.00, respectively. Set annuallnterestrate to 4%, then calculate the monthly interest and print the new balances for both savers. Then set the annualinterestRate to 5%, calculate the next month's interest and print the new balances for both savers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Identify job situations that often present ethical dilemmas.

Answered: 1 week ago