Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Trying to figure out next step

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to figure out next step

    I am trying to create a stand-alone app that calculates the sales tax for products input by the user. I'm not sure if I'm supposed to have it in a frame, or what I'm missing to complete the process.
    //Sales Taxes Calculator
     
    package SalesTaxesApp;
     
    import.java.util.Scanner;
    import.java.util.Arrays;
     
    public class SalesTaxApp{
    public static void main(String[] args)
    class tax{
    	int qty=0;
    	String prodName="null";
    	float price="false";
    	boolean imported="false";
    	boolean basic="false";
    	float tax=0.0f;
     
    	void calculateTaxes(){
    		float totalTax=0.0f;
    		if (imported)
    		totalTax=0.05;
    		if (basic)
    		totalTax=0.1;
    		if (imported)&&(basic)
    		totalTax=0.15;
    		tax=price*totalTax;
    	}
    		public String toString(){
    			float p=price+tax;
    			return qty+""+prodName+":"+p;
    		}
    }
    	public class SalesTax{
    		public staic void main(String[] args) throw Exception{
    			SalesTax st=new SalesTax();
    			Scanner input=new Scanner(System.in);
    			ArrayList list= new ArrayList();
    			int no=1;
    			while (true){
    				Tax tax=new Tax();
    				System.out.print("Quantity:")
    				int qty=input.nextInt();
    				tax.qty=qty;
    				System.out.print("Product:");
    				String prod=input.net();
    				tax.prodName=prod;
    				System.out.print("Price:");
    				float p=input.nextFloat();
    				tax.price=p;
    				System.out.print("Product Imported[y/n]:");
    				String imp.=input.next();
    				if (imp.toLowerCase().equals("y"))
    				tax.basic=true;
    				tax.calculateSalesTaxes();
    				list.add(tax);
    				no++;
    				System.out.print("Additional Products[y/n]:");
    				String add=input.next();
    				if(add.toLowerCase().equals("n"))
    				break;
    		}
    				float tp=0.0f;
    				float tt=0.0f;
    				for (int i=o; i<list.size(); i++{
    					Tax tax=list.get(i);
    					tp+=tax.price;
    					tt+=tax.tax;
    					System.out.print(tax);
    				}
    					System.out.println("Sales Tax:"+tt);
    					System.out.println("Total:"+(tt+tp);
    	    }
    }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Trying to figure out next step

    If this is an assignment then the instructions will tell you.

    If this is your own pet project you decide if you need a GUI or not.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to figure out next step

    fair enough. Am I at least correct with what I have thus far?

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Trying to figure out next step

    I have no idea. Does it compile? Does it run? Does it display correct output?
    Improving the world one idiot at a time!

Similar Threads

  1. [SOLVED] Single step debug in Eclipse
    By Sharmeen in forum Java IDEs
    Replies: 1
    Last Post: October 20th, 2012, 09:42 AM
  2. On line step by step Java Tutorial
    By Sylva in forum The Cafe
    Replies: 3
    Last Post: August 11th, 2012, 05:34 PM
  3. Step by step process to implement SSL
    By balajikrb@gmail.com in forum Java Networking
    Replies: 0
    Last Post: April 20th, 2012, 09:55 AM
  4. Next step in Java
    By Melawe in forum Java Theory & Questions
    Replies: 10
    Last Post: December 10th, 2011, 12:44 AM
  5. A question About Java (whats my next Step?)
    By DarrenReeder in forum Java Theory & Questions
    Replies: 4
    Last Post: December 7th, 2009, 03:51 AM