15,559,976 members
See more:
QUESTION

create JAVA code to display the number of dollars and cents based on user numeric input. For instance, if the user inputs 540, the program will display 5 dollar and 40 cent in a message dialog. For this program you will use integer arithmetic and will need to avoid floating point arithmetic. If user entered floating numbers, program will prompt a warning message.

How to create a JAVA code?What the formula?Thanz
Posted
Updated 7-Nov-12 4:20am
v3
Sergey Alexandrovich Kryukov 6-Nov-12 13:36pm
A formula? (sigh...)...
--SA
TorstenH. 7-Nov-12 1:22am

Solution 1

create JAVA code to display the number of dollars and cents based on user numeric input. For instance, if the user inputs 540, the program will display 5 dollar and 40 cent in a message dialog. For this program you will use integer arithmetic and will need to avoid floating point arithmetic. If user entered floating numbers, program will prompt a warning message.

v2

Solution 3

C#
```/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Keja
*/
import javax.swing.*;
import javax.swing.JOptionPane;
public class RinggitSen
{

public static void main(String args [])
{
// Declaration of variables.
int ringgit;
int sen;
String inputNumberString;
int inputNumber;
JFrame frame;
frame = new JFrame("Message Dialog");
// Get interactive user input
inputNumberString = JOptionPane.showInputDialog("Enter Number: ");

// Convert String to int
inputNumber = Integer.parseInt(inputNumberString);

// Calculate the number
ringgit = inputNumber / 100;
sen = inputNumber % 100;

// Output the result
JOptionPane.showMessageDialog(frame, ringgit + " Ringgit " + sen + "Sen" );
}
}```