|
|
| Java Programming and Coding problem |
Expert:Ron Singh
How write a program that helps the user count his change. The program should ask how many quarters the user has, then how many dimes, then how many nickels, then how many pennies. Then the program should tell the user how much money he has, expressed in dollars? Please reply as soon as you can. It's very necessary. Thank you very much. |
| Answers |
Hi buddy I hope this code helps you
import java.io.*; import javax.swing.JOptionPane;
class count {
public static void main(String[] args) {
int quarters,dimes,nickels,pennies; int money=0;
quarters=Integer.parseInt(JOptionPane.showInputDialog("Enter QUARTERS:")); money=money + quarters;
dimes=Integer.parseInt(JOptionPane.showInputDialog("Enter Dimes:")); money = money + dimes;
nickels=Integer.parseInt(JOptionPane.showInputDialog("Enter NICKELS:")); money = money + nickels;
pennies=Integer.parseInt(JOptionPane.showInputDialog("Enter Pennies:")); money = money + pennies;
String str=new String("you have $"); str=str+money;
JOptionPane.showMessageDialog(null,str);
}
}
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|