Solved

SALES TAX Java problem solution??

Posted on 2016-09-26
6
55 Views
Last Modified: 2016-10-17
Can someone please let me know the solution to this problem ?

Problem statement :

The Michigan Legislature is trying to find a way to fund road repair. One of the options that was proposed (and rejected by the voters) was to raise the sales tax by one percent. One would assume that it is still possible that such as increase could still occur, if other funding sources are not found. Create a Java class named SalesTax that helps you figure out how the possible one percent increase in the Michigan sales tax will affect you. The program will read in your current yearly total income, and also read in the percent of that income you think is spent on items that get hit by the Michigan sales tax (just the sales tax - ignore federal income taxes, state income taxes, money spent on non-taxable purchases like food, etc.). Your program will then show you how much of your income is spent on taxable items, how much tax you currently pay on those expenditures (at 6%), how much you would pay at 7%, and finally the program will show the difference between the 6% and the 7% payments.

Your program should accept any reasonable values for income (zero to a couple of million), and any reasonable value for "pecent of income (0 to 100 percent). You don't need to do any error checking of the values -- just assume that the user will type in reasonable values.

You don't have format the monetary values so that they look as nicely formatted as what is shown in the sample output, since that output was generated with printf. For example, my program might show exactly two digits after the decimal point, and a comma every third digit before the decimal point, as might be shown in the first line of calculated output as:

            Taxable income: $7,805.31

In that line the monetary value is shown as "7,805.31", whereas the simple print and println methods we've used so far might print "7805.3125". This doesn't look as good as the "7,805.31" I generated with printf, but the "7805.3125" output you get with print and println is perfectly acceptable.
0
Comment
Question by:Mirim Lee
6 Comments
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41816727
Is this a homework exercise?
0
 

Author Comment

by:Mirim Lee
ID: 41816734
No, it's one of my test review exercise, that I just can't figure out~
0
 
LVL 27

Expert Comment

by:dpearson
ID: 41816736
Mirim you should post your best effort at the solution and then ask specific questions about what you're having problems with.  Then we may be able to help.

Doug
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Mirim Lee
ID: 41820813
import java.util.Scanner;

public class SalesTax
{
   public static void main(String[] args);
   {
      double income = 2100.0;  // To hold the user's income
      double percent; = 0.25; // percent of income
      double taxableIncome = 5250.0;
      
      // Create a Scanner object to read input
      Scanner keyboard = new Scanner(System.in);
      
      // Get the user's current income
      System.out.println("What is your current income?");
      income = keyboard.nextDouble();
      
      // Get the user's percent of income
      System.out.println("What percent of your income is taxable?(0 to 100)");
      percent = keyboard.nextDouble();
      
      // Get the user's taxable inccome
      System.out.println("Taxable income);
      taxableIncome = keyboard.nextDouble
      
      // Calculate and display current 6% tax
      income = taxableIncome * 0.06;
      System.out.println("At 6% tax");
      
      // Calculate and display current 7% tax
      income = taxableIncome * 0.07;
      System.out.println("At 7% tax");
      
       // Calculate and display difference
      System.out.println("Difference");
      
      double total = ( - );
   }
}

Open in new window

     
This is what I got so far and it's showing these errors:
SalesTax.java:15: error: illegal start of expression
      double percent; = 0.25; // percent of income
                      ^
SalesTax.java:30: error: unclosed string literal
      System.out.println("Taxable income);
                         ^
SalesTax.java:30: error: ';' expected
      System.out.println("Taxable income);
                                          ^
SalesTax.java:31: error: illegal start of expression
      taxableIncome = keyboard.nextDouble
                    ^
SalesTax.java:31: error: ';' expected
      taxableIncome = keyboard.nextDouble
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points (awarded by participants)
ID: 41820950
This is a little too close to homework to provide the exact answer but the main issue is a little hard to hint at.

Look for a single misplaced character?

Start with the simple examples available out there:
https://docs.oracle.com/javase/tutorial/getStarted/application/

Compare that with your code.  See anything different?


The example code:
class HelloWorldApp {
    public static void main(String[] args) {
  

Open in new window


Your code:
public class SalesTax
{
   public static void main(String[] args);
   {

Open in new window

0
 
LVL 27

Expert Comment

by:dpearson
ID: 41846315
This leads to the answer without completely revealing it.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 40
by zero exception 10 52
jsp insert to database example 2 47
Java: anonymous class 4 29
Finding a job can be stressful - searches, resume tweaks, and networking events can be super boring. Luckily we're here to help you land your dream job!
Whether you believe the “gig economy,” as it has been dubbed, is the next big economic paradigm shift (https://www.theguardian.com/commentisfree/2015/jul/26/will-we-get-by-gig-economy) or an overstated trend (http://www.wsj.com/articles/proof-of-a-g…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question