Concept explainers
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 that takes the invoice number
public void setInvoiceNumber(int num)
{
//Assign the value
invoiceNumber = num;
}
//Define a set method that takes the amount of sale
public void setSaleAmount(double amt)
{
//Assign the value
saleAmount = amt;
//Compute the sales tax
tax = saleAmount * RATE;
}
//Define a get method that returns the amount of sale
public double getSaleAmount()
{
//Return the value
return saleAmount;
}
//Define a get method that returns the invoice number
public int getInvoiceNumber()
{
//Return the value
return invoiceNumber;
}
/*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: “SortPurchasesArray.java”
//Import necessary header files
import java.util.Scanner;
//Define a class named SortPurchasesArray
public class SortPurchasesArray
{
//Define a main method
public static void main(String[] args)
{
//Declare an array of five Purchase objects
Purchase[] purchases = new Purchase[5];
//Declare the variables
int i;
String message;
char choice;
final char QUIT = 'Z';
int number;
double price;
//Create an object for Scanner class
Scanner keyboard = new Scanner(System.in);
//For loop to be executed until i exceeds 5
for(i = 0; i < purchases.length; ++i)
{
//Prompt the user to enter the invoice number
System.out.print("Enter invoice number >> ");
number = keyboard.nextInt();
//Prompt the user to enter the amount of sale
System.out.print("Enter sale amount >> ");
price = keyboard.nextDouble();
purchases[i] = new Purchase();
//Function call
purchases[i].setInvoiceNumber(number);
purchases[i].setSaleAmount(price);
}
keyboard.nextLine();
/*Prompt the user to enter whether the Purchase objects
should be sorted and displayed in invoice number
order or sale amount order*/
System.out.print("\nSort Purchases by (I)nvoice number, or (S)ale amount? ");
choice = keyboard.nextLine()...
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Java Programming, Loose-Leaf Version
- Please original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinksarrow_forwardWhat is cloud computing and why do we use it? Give one of your friends with your answer.arrow_forwardWhat are triggers and how do you invoke them on demand? Give one reference with your answer.arrow_forward
- Discuss with appropriate examples the types of relationships in a database. Give one reference with your answer.arrow_forwardDetermine the velocity error constant (k,) for the system shown. + R(s)- K G(s) where: K=1.6 A(s+B) G(s) = as²+bs C(s) where: A 14, B =3, a =6. and b =10arrow_forward• Solve the problem (pls refer to the inserted image)arrow_forward
- Write .php file that saves car booking and displays feedback. There are 2 buttons, which are <Book it> <Select a date>. <Select a date> button gets an input from the user, start date and an end date. Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, it books cars for specific dates, with bookings saved. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. In the booking.json file, if the Car ID and start date and end date matches, it fails Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert).arrow_forwardWrite .php file with the html that saves car booking and displays feedback. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. There are 2 buttons, which are <Book it> <Select a date> Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, book cars for specific dates, with bookings saved. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert). And then add an additional feature that only free dates are selectable (e.g., calendar view).arrow_forward• Solve the problem (pls refer to the inserted image) and create line graph.arrow_forward
- who started the world wide webarrow_forwardQuestion No 1: (Topic: Systems for collaboration and social business The information systems function in business) How does Porter's competitive forces model help companies develop competitive strategies using information systems? • List and describe four competitive strategies enabled by information systems that firms can pursue. • Describe how information systems can support each of these competitive strategies and give examples.arrow_forwardData communıcatıon digital data is transmitted via analog ASK and PSK are used together to increase the number of bits transmitted a)For m=8,suggest a solution and define signal elements , and then draw signals for the following sent data data = 0 1 0 1 1 0 0 0 1 0 1 1arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,