View Single Post
  #10 (permalink)  
Old 11-14-2007, 04:44 PM
Phobos0001 Phobos0001 is offline
Member
 
Join Date: Nov 2007
Posts: 20
Phobos0001 is on a distinguished road
Finnished
well ive finaly finnished my program, so no further help required, incase anyone wants to see it and tell me how much it sux....here it is..
Code:
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, such as string length public class test //defines class name and access rihts, public=everyone { public static void main(String[] args) //begins body { String agebox, namebox; //assigning variables names and datatypes double fee, age, tax, total, ffee, fage, ftax, ftotal, average; int count; fee = 20.50; //initialising variables that require manual initialisation ffee = 0; fage = 0; ftax = 0; ftotal = 0; count = 0; average = 0; 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 int len=namebox.length(); //declaring len as lenght of the namebox string while (len !=0) { 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);} //warn operater of young age 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 namebox =JOptionPane.showInputDialog("Enter Member's Name, leave blank to exit member entry "); // user input for name len=namebox.length(); //declaring len as length of the namebox string fage=age+fage; ffee=fee+ffee; ftax=tax+ftax; ftotal=total+ftotal; count++; average=fage/count; } JOptionPane.showMessageDialog(null, "Today's totals are..." + "\ntotal age is: " + fage + "\ntotal fee is " + ffee + "\ntotal tax is: " + ftax + "\ntotal including tax is: " + ftotal + "\nAmmount of costimers today: " + count + "\nAverage age: " + average, "Gym Program", JOptionPane.INFORMATION_MESSAGE); //display's information of the current member JOptionPane.showMessageDialog(null,"Thanks for using the program","beyatch",JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }
Reply With Quote