View Single Post
  #2 (permalink)  
Old 11-13-2007, 01:32 PM
Phobos0001 Phobos0001 is offline
Member
 
Join Date: Nov 2007
Posts: 20
Phobos0001 is on a distinguished road
ok, this is what i have thus far on my program....
---------------------------------
import javax.swing.*; //impors java gui for dialog boxes ect
import java.text.*; //imports java texts for text formatting
import java.io.*; //imports input output detection and information (i think i need this)

public class test //defines class name and access
{
public static void main(String[] args) //begins body
{
String agebox, namebox; //assigning variables names and datatypes
double fee, age, tax, total;

fee = 20.50; //initialising variables that require manual initialisation

DecimalFormat num = new DecimalFormat(",##.00"); //formatting the text

namebox =JOptionPane.showInputDialog("Enter Member's Name, leave blank to exit member entry "); // user input for name
agebox =JOptionPane.showInputDialog("Enter Member's Age: "); //user input for age
age = Double.parseDouble(agebox); // assign age as a double for if-else chain

if (age <= 7 ) //if-else chain for the member's fee
{JOptionPane.showMessageDialog(null,"Warning Member's age is too low to leave unsurpervised",
"WARNING!",
JOptionPane.WARNING_MESSAGE);}
else if (age <=17)
{ fee = 20.50;}
else if (age <=21)
{ fee = 32.25;}
else
{ fee = 45.75;} //end of if else chain

tax = fee*10/100; //calculating tax and assigining it to a variable
total = tax + fee; // adding fee and tax and assiginging it to a variable

JOptionPane.showMessageDialog(null,
"The member's name is " + namebox + "\nThe Member's age is " + agebox + "\nMember's fee is " + fee + "\nMember's tax is " + tax + "\nMember's fee including tax is " + total,
"Gym Program",
JOptionPane.INFORMATION_MESSAGE); //display's information of the current member

System.exit(0);
}
}
-----------------------------------------
it will probably be a nasty unclean bit of code for you pro's but im still learning (hence the large ammount of comments heh heh )
Reply With Quote