All chocolate bars today cost $0.99. Ask for the name of any chocolate bar to be entered. Also ask for the quantity of bars wanted. Leave a blank line, then use "\t" to display the name, quantity, and total cost, with the heading in capital, as follows...
CHOCOBAR________QUANTITY_________ COST
Kitkat_____________3______________$2.97
(stupid forum wont let me use more then one space in between so i had use "_")
Okay i got a two problems here...Code:import javax.swing.JOptionPane; public class Chocs { ****public static void main(String[] args) ****{ ********String name = JOptionPane.showInputDialog("Chocolate bar name?"); ******** ********String bars = JOptionPane.showInputDialog("How many?"); ********int chocob = Integer.parseInt(bars); ********int costtot = (int) (chocob * 0.99); ********String line = " CHOCBAR********QUANTITY********COST"; ********String line1 = name+****bars+****costtot; ********System.out.println(line); ********System.out.println(line1); ******** ********System.exit(0); ******** ****} }
- out put for costtot is being rounded to the nearest whole number
- my out put is looking like this, i think it might be because i didn't add "\t" ? i dont know what \t does?
its all crunched up instead of having the spacing i added in String line1
P.S. its homework if you where wondering whats up with the choc bars lol
Bookmarks