Solved

SALES TAX Java problem solution??

Posted on 2016-09-26
6
58 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 34
Eclipse with various Java releases 7 42
java mysql insert application 14 41
where can I find 80's pinball games for pc? 5 56
Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This video teaches viewers about errors in exception handling.
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.

680 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