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 method to set the invoice number
public void setInvoiceNumber(int num)
{
invoiceNumber = num;
}
//Define a method to set the amount of sale
public void setSaleAmount(double amt)
{
saleAmount = amt;
//Calculate the amount of sales tax
tax = saleAmount * RATE;
}
/*Define a method to display the invoice number,
amount of sale, and amount of sales tax*/
public void display()
{
//Print the result
System.out.println("Invoice #" + invoiceNumber +
" Amount of sale: $" + saleAmount + " Tax: $" + tax);
}
}
File name: “PurchaseArray.java”
//Import necessary header files
import java.util.*;
//Define a class named PurchaseArray
public class PurchaseArray
{
//Define a main method
public static void main(String[] args)
{
//Declare a purchases object
Purchase[] purchases = new Purchase[5];
//Declare the variables
int num;
double amount;
String entry;
//Create an object for Scanner class
Scanner input = new Scanner(System.in);
//Declare the variables and initialize the values
int x;
final int LOW = 1000, HIGH = 8000;
//For loop to be executed until x exceeds 5
for(x = 0; x < purchases.length; ++x)
{
purchases[x] = new Purchase();
//Prompt the user to enter an invoice number
System.out.print("Enter invoice number >> ");
num = input...
Want to see the full answer?
Check out a sample textbook solution- answer shoul avoid using AI and should be basic and please explainarrow_forwardNode A is connected to node B by a 2000km fiber link having a bandwidth of 100Mbps. What is the total latency time (transmit + propagation) required to transmit a 4000 byte file using packets that include 1000 Bytes of data plus 40 Bytes of header.arrow_forwardanswer should avoid using AI and should be basic and explain pleasearrow_forward
- answer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardanswer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardWrite a c++ program that will count from 1 to 10 by 1. The default output should be: 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, —help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter, counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr