Solved

# SALES TAX Java problem solution??

Posted on 2016-09-26
39 Views
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
Question by:Mirim Lee

LVL 15

Expert Comment

ID: 41816727
Is this a homework exercise?
0

Author Comment

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

LVL 26

Expert Comment

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

Author Comment

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
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 = ( - );
}
}
``````

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 76

Accepted Solution

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?

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) {

``````

``````public class SalesTax
{
public static void main(String[] args);
{
``````
0

LVL 26

Expert Comment

ID: 41846315
0

## Featured Post

### Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.