Jump to content

Need help in Java

PugoOfficial

So here's the question .. (Sorry I was absent that day that's why I couldn't understand what methods/attributes to use I'm so Confused if someone can give me a program I'll try to understand it :) )

 

- Write a Java Program that calculates the change for a cashier. The Program requests the cost of the item. The user then types in the cost. The Program then outputs the cost of the item including the sales tax (6% as the tax value). The program next requests and receives the amount tendered by the customer. Finally the program outputs the summary of all figures including the amount of change due to the customer

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

So here's the question .. (Sorry I was absent that day that's why I couldn't understand what methods/attributes to use I'm so Confused if someone can give me a program I'll try to understand it :) )

 

- Write a Java Program that calculates the change for a cashier. The Program requests the cost of the item. The user then types in the cost. The Program then outputs the cost of the item including the sales tax (6% as the tax value). The program next requests and receives the amount tendered by the customer. Finally the program outputs the summary of all figures including the amount of change due to the customer

 

no. try it yourself and if you get stuck you will get the help needed.

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
Share on other sites

Link to post
Share on other sites

no. try it yourself and if you get stuck you will get the help needed.

Ok I understand here's my problem now ..

import java.io.*;	class Change {				public static void main (String [] args) throws IOException {						System.out.println("Please enter the cost of the item:");						BufferedReader fc = new BufferedReader (new InputStreamReader(System.in));			String cost = fc.readLine();			double z = Double.parseDouble(cost);							System.out.println("Cost of the item: " +z);		}	}

I don't know how to add the tax to the price of the item the user entered.

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

Well that is a mathematical problem.

 

cost(incl tax) = cost(w/o tax) * 1 + cost(w/o tax) * taxrate

double cost = 10;double tax = 0.09; // 9%double costAfterTax = cost + cost * tax; // costAfterTax == 10.9

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
Share on other sites

Link to post
Share on other sites

Ok I understand here's my problem now ..

 

amount tendered works like the request for the cost of the item.

 

change = amountTendered - costAfterTax

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×