12,076,727 members (46,038 online)
Rate this:
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 6-Nov-12 7:55am
Edited 7-Nov-12 4:20am
v3

A formula? (sigh...)...
--SA
TorstenH. 7-Nov-12 1:22am

Rate this:

Rate this:

## 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
Rate this:

## Solution 3

```/*
* 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" );
}
}```

Top Experts
Last 24hrsThis month
 Jochen Arndt 350 Richard MacCutchan 340 Sergey Alexandrovich Kryukov 319 OriginalGriff 275 F-ES Sitecore 220
 OriginalGriff 2,855 Dave Kreskowiak 2,836 Richard MacCutchan 2,174 CPallini 1,632 Sergey Alexandrovich Kryukov 1,416