I'm having a problem with my SalesTax program. The problem is my array of doubles won't show up in the frame "amount". The doubles show up in the console view in eclipse but i'm trying to get the doubles such as (Enter Item, Next Item) to show up in the frame "amount". In the constructor for "amount" i haven't instantiated the doubles because so far i have only learned to instantiate things like textfields, textareas, labels, & buttons.
I would like to for these doubles to display in the amount frame similar to the console view in eclipse.
Thanks in advance
import static java.lang.Math.*;
import java.awt.GridLayout;
import java.util.Scanner;
import javax.swing.JFrame;
import java.awt.*;
public class SalesTax extends JFrame {
public SalesTax(){
super("Amount");
setSize(300,300);
setLocation(100,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBackground(java.awt.Color.lightGray);
setLayout(new GridLayout(12,12));
setVisible(true);
//Create a Scanner
Scanner input = new Scanner(System.in);
// Enter Your Item Value
System.out.print("Enter Item: ");
double retail = input.nextDouble();
//Enter 2nd Item Value
System.out.print("Next Item:");
double retail2 = input.nextDouble();
//Add both items
double total = (retail + retail2);
// Calculate Tax on Both Items
double tax = (total) * .0725;
//Total Amount Due
double amount = (total + tax);
// Display result
System.out.printf("Your total is $%.2f", total, Math.ceil(total));
System.out.println();
System.out.printf("Your tax is $%.2f", tax, Math.ceil(tax));
System.out.println();
System.out.printf("Total due is $%.2f", amount, Math.ceil(amount));
setVisible(true);
}
public static void main(String[] args) {
SalesTax test = new SalesTax();
}
}
This post has been edited by pbl: 12 March 2009 - 04:47 PM

New Topic/Question
Reply




MultiQuote





|