Write an application containing a main method

Assignment Help JAVA Programming
Reference no: EM131299469

Write a Java program that meets the following requirements:

A. Create a class named "Invoice" that holds an invoice numner, balance due, and three fields representing the month, day and year when the balance is due. Create a constructor that accepts values for all five data fields. Within the constructor, assign each argument to the appropriate field with the following exceptions:

·If an invoice number is less t han 1000, force the invoice number to 0.
·If the month field is less than 1 or greater than 12, force the month field to 0.
·If the day field is less than 1 or greater than 31, force the day field to 0.
·If the year field is less than 2011 or greater than 2017, force the year field to 0.

In the "Invoice" class, include a display method that displays all the fields on an Invoice object. Save the file as "Invoice.java".

B. Write an application containing a main() method that declares several Invoice objects, proving that all the statements in the constructor operate as specified. Save the file as "TestInvoice.java".

C. Modify the constructor in the Invoice class so that the day is not greater than 31, 30, or 28, depending on the month. For example, if a user tries to create an invoice for April 31, force it to April 30. Also, if the month is invalid, and thus forced to 0, also force the day to 0. Save the modified Invoice class as Invoice2.java. Then modify the TestInvoice class to create Invoice2 objects. Create enough objects to test every decision in the constructor. Save this file as "TestInvoice2.java".

Purpose:

Create a java program from detailed directions.

Ability to:

Follow established programming conventions for writing java programs
Create a class
Instantiate an object
Create a constructor to override the default constructor
Able to write nested IF statements
Use the print statement for output.

Reference no: EM131299469

Questions Cloud

Write a short paragraph of three correct sentences : Write a short paragraph of three correct sentences (NB: using ONLY your own sentences) for each of the following sets of words. Principal (adjective) and principle (noun). Dependent and dependant
Display a frequency chart for each exam score in the array : Create a Java application that contains methods to display statistics for the numbers in an array. Receive the array as an argument and display a frequency chart for each exam score in the array.
Standard deviations of the distributions : The standard deviations of the distributions of b2 and b3 for the 10 million samples in Figure 3.5 are both 0.45. Verify that this is what you would expect theoretically, given that the correlation between X2 and X3 is 0.9962 and that S22 = 665 an..
What advantages do they hold over their competitors : What companies or organizations in the Kingdom of Saudi Arabia have been rethinking their markets and what advantages do they hold over their competitors?
Write an application containing a main method : Write an application containing a main() method that declares several Invoice objects, proving that all the statements in the constructor operate as specified. Save the file as "TestInvoice.java".
What is the minimum value of the convection heat transfer : what is the minimum value of the convection heat transfer coefficient expressed in terms of the sphere diameter and thermal conductivity of the air?
Identify the errors in the php code provided : Identify the errors in the PHP code provided for you in assignment6.php (Download ZIP). Correct the code and create comments explaining why the original code would not work properly.
Lifetime budget constraint of the consumer : 1) Write down the lifetime budget constraint of the consumer. 2) Show that lifetime wealth is the same for the consumer, before and after the change in tax rates.
Why the teller application can call the withdraw methods : Explain why the Teller application can call the withdraw and deposit methods using a SavingsAccount object reference, even though we did not define these methods.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write, compile and run a standalone java application

Write, compile and run a standalone Java application that displays an output line on the console.

  Code 2-dimensional array that stores the average scores

Instructions: Code a 2-dimensional (2D) array that stores the average scores for 2 football teams across 2 years. In a method called setAvgScores, prompt for the averages and store them in the 2D array which will be returned

  Advance programming hi i want two copies of the assignment

hi ltbrgti want two copies of the assignment me and my friend are doing same assignment. ltbrgtwe need both the

  What are the main differences between javabeans and applets

What are the main differences between JavaBeans and applets? How do I use an applet that resides on a remote machine?

  Inheriting from the jframe class

What is the difference between inheriting from the JFrame class and using a JFrame member variable?

  Write a loop that will print out the value

Given the subsequent code segment that reads in a String str - Write a loop that will print out the value entered into str in reverse.

  Write a java program that can serve as a simple calculator.

Write a Java program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0.

  The goal is to create a project that would let a user

the goal is to create a project that would let a user compute area and perimeter of a polygon. restrict the type of

  1 explain the differences between our specifications of the

1. explain the differences between our specifications of the sorted list adt and the binary search tree adt.2. define a

  Create a program that holds a simple address book

Create a class HashTable which implements HashTableInterface with buckets. You can use an array of linked lists(of Person objects).You may add any other methods you think are necessary.

  Determining the taylor series

Suppose that you are told that the Taylor series of f(x)=x3ex^3 about x = 0 is x3+x6+(x9/2!)+(x12/3!)+(x15/4!)+...

  Write a very simple data maintenance java program

In this assignment, you will write a very simple data maintenance Java program for a small computer retail store (like Staples).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd