Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming through Eclipse. This is an intro into comupter science class. We are working on modifying the following code: Calculate 6% sales tax on

Java programming through Eclipse. This is an intro into comupter science class. We are working on modifying the following code:

Calculate 6% sales tax on a given sales amount. (Use a constant for the tax percentage 6%)

* * Analyze * * Input: double amount, constant double TAXRATE (0.18) * Process: none * Output: tax * * Design * * input amount * calculate tax: amount * TAXRATE * output amount, TAXRATE, and tax * */

import java.util.*;

public class sales_tax { public static final double TAXRATE = 0.18; // note how I declared a constant outside of main. You may declare it like this or inside of main as in your textbook

public static void main(String[] args) { double amount, tax; Scanner input = new Scanner(System.in);

System.out.println("Sales tax calculator at " + TAXRATE*100 + "%"); // a title for the whole program // input amount System.out.print("Enter the sales amount: $"); amount = input.nextDouble(); //calculate tax: amount * TAXRATE tax = amount * TAXRATE; //output amount, TAXRATE, and tax System.out.println(); System.out.println("Sales amount: $" + amount); System.out.println("Sales Tax %: " + TAXRATE * 100); System.out.println("Tax: $" + tax); input.close(); // optional }

}

Calculate a discount as follows:

- For all amounts greater than or equal to $100 the customer receives a 10% discount, otherwise they

receive a 5% discount

Calculate the total due as follows:

- amountdiscount + tax

Output the amount, discount, tax and due

- The tax is calculated on the discounted amount. A process variable subtotal may be useful here.

Use printf and escape characters to format your output nicely.

2 Sample inputs and outputs:

Total due calculation program

Enter the sales amount: $100

Bill Summary:

sales amount: $100.00

discount: $10.00

tax (at 6.00%): $5.40

Total due: $95.40

Total due calculation program

Enter the sales amount: $99.99

Bill Summary

:

sales amount: $99.99

discount: $5.00

tax (at 6.00%): $5.70

Total due: $100.69

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain how technology has changed the learning environment.

Answered: 1 week ago