Results 1 to 6 of 6

Thread: Java help needed

  1. #1
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default Java help needed

    Hello!

    I am taking a basic Java course and was hoping for some help. I have a test coming up soon and I was hoping if someone quickly jot down some code for these questions (sample test) so I can study them and learn the process. Also maybe some comments on the side to let me know what is going on each line/block.




    Problem 2


    You are asked to create a program that calculates a tax table for a city where there is a city, county, and state tax. The city tax rate is 10%, the county rate is 5%, and the state rate is 1.2%. The state rate is not applicable unless the purchase is over $3,000.00, and the county rate only applies if the purchase is over $10,000.

    a) In the space below, calculate the total amount due in taxes for a purchase of $11000. Show all your work, including the amount of each tax individually.

    b) Sketch a flow chart for determining the total tax rate. Ask the user to enter all the tax rates and a purchase amount first, then show all the steps to calculate and print the correct tax amount.


    c) Assume that you have a function
    Code:
    public static doublecalculateTaxAmount(double purchaseAmount, double cityTaxRate,
                                          double countyTaxRate,
                                          double stateTaxRate)
    In the space below, write the code that you would use to calculate the total tax due based on your flowchart in part (b). The function should return the total taxes owed. Note that the func- tion's parameters include the purchase amount and all the tax rates, so your function should not include reading the values from the user (i.e., no Scanner is required).

  2. #2
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    I mean, someone could write the solutions for you, but do you actually know any Java yet? These are very basic problems that you should be able to solve pretty quickly. Could you post your attempts first?



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  3. #3
    Join Date
    May 2012
    Location
    USA
    Posts
    169
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    #1 is really good practice if you're still learning. I'd suggest trying it yourself and then posting here.

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    http://imgur.com/a/ejdfk

    Edit: Re-uploaded correct version to "2b". I figure the rest you should be able to do on your own. Otherwise you won't make it through that test.
    Last edited by Brandon; 03-07-2016 at 02:53 AM.
    I am Ggzz..
    Hackintosher

  5. #5
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    http://imgur.com/a/ejdfk

    Edit: Re-uploaded correct version to "2b". I figure the rest you should be able to do on your own. Otherwise you won't make it through that test.
    Is that your actual handwriting? It looks really sexy

  6. #6
    Join Date
    May 2014
    Posts
    633
    Mentioned
    8 Post(s)
    Quoted
    322 Post(s)

    Default

    Shouldn't this be trivially solved with if/elses nested properly? Like having an outer check for >3k and then a check inside that for >10k for the second one. Converting the chart to code should be pretty trivial, just convert the yes/no nodes to if/elses.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •