EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6, Problem 15PE

a.

Explanation of Solution

Program:

File name: “Purchase.java

//Define a class named Purchase

public class Purchase

{

    //Declare the private variables

    private int invoiceNumber;

    private double saleAmount;

    private double tax;

    private static final double RATE = 0.05;

    //Define a set method for the invoice number

    public void setInvoiceNumber(int num)

    {

        invoiceNumber = num;

    }

    //Define a set method for the sale amount

    public void setSaleAmount(double amt)

    {

        //Calculate the sales tax as 5% of the sale amount

        saleAmount = amt;

        tax = saleAmount * RATE;

    }

�...

b.

Explanation of Solution

Program:

File name: “CreatePurchase.java

//Import necessary header files

import javax.swing.*;

//Define a class named CreatePurchase

public class CreatePurchase

{

    //Define a main method

    public static void main(String[] args)

    {

        //Declare Purchase object

        Purchase purch = new Purchase();

        //Declare the variables

        int num;

        double amount;

        String entry;

        final int LOW = 1000, HIGH = 8000;

        //Prompt the user to enter the invoice number

entry = JOptionPane.showInputDialog(null, "Enter invoice number");

        num = Integer.parseInt(entry);

        /*While the user does not enter a number between 1,000 and 8,000*/

        while(num <= LOW || num >= HIGH)

        {

            //Print the message

entry = JOptionPane.showInputDialog(null, "Invoice number must be between " +

            LOW + " and " + HIGH + "\nEnter invoice number");

            num = Integer...

Blurred answer
Students have asked these similar questions
Now code an application that declares a purchase object and prompts the user for purchase details. When this prompt is made, do not allow the user to proceed until a number between 1000 and 6000 inclusive has been entered. When the system prompts for a sale amount, it must not proceed until the user has entered a non-negative value. In the event a valid purchase object has been created, display the object’s invoice number, sale amount and sales tax
You are required to create a console application for a technology retail outlet that will allow a user to print out the total price of a product including VAT of 14%.The program must prompt the user for a product name , the price and print the final price including VAT. The retail outlet provides 5% discount to all products that have a final price that is greater than or equal to 10 000 In  your solution include a class called products. The class must include the following: Two variables to store the product name and price excluding VAT; A method to return the product name  A method to calculate and return the product price including VAT; Print the product name and the final price in the main() method with suitable wording Use java language
jada please Create a class named Purchase. Each Purchase contains an invoice number, amountof sale and sales tax. Include getter and setter methods for each property.Write a method called InvoiceTotal to compute the total of invoice. Save this infile called Purchase.javaCreate another class with the following:In this class, create a Purchase Object after prompting the user for necessarydetails.(You need to figure out what to ask the user for).When you prompt the user for invoice number do not let the user proceed unlessthe invoice number is between 5 and 55.For sales amount do not let the user proceed if they enter a negativevalue. After instantiating a Purchase object, show all the properties ofthe invoice object.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY