I'm taking a Java class which I am really liking so far. So I have this problem I am working on now.
A. Create a class name purchase. Each purchase. Contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set() method for the sale amount, calculate the sales tax as 5% of the sale amount. Also include a display method that displays a purchase's details. Save the file as purchase.java
The issue I am having is the other two methods are not printing (sale2 and sale3). then on top of that I cannot get the final price to print 2 decimal places. It does not seem double or int will work, so what other options do I have?
Thanks for the ideas folks.
public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { int invoice1 = 25; int invoice2 = 28; double amtSale1 = 18.99; double amtSale2 = 39.59; double amtSale3 = 75.89; double tax = 1.05; sale1 (invoice1, amtSale1, tax); } public static int sale1(int invoice1, double amtSale1, double tax) { double total = tax * amtSale1; System.out.println("The invoice number is " + invoice1 + ". And the total with 5% tax is $" + total); double newAmount; newAmount = total; return (int) newAmount; } public static int sale2(int invoice2, double amtSale2, double tax) { double total = tax * amtSale2; System.out.println("The invoice number is " + invoice2 + ". And the total with 5% tax is $" + total); double newAmount; newAmount = total; return (int) newAmount; } public static int sale3(int invoice3, double amtSale3, double tax) { double total = tax * amtSale3; System.out.println("The invoice number is " + invoice3 + ". And the total with 5% tax is $" + total); double newAmount; newAmount = total; return (int) newAmount; } }