Click here to Skip to main content
15,559,976 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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
Comments
Sergey Alexandrovich Kryukov 6-Nov-12 13:36pm    
A formula? (sigh...)...
--SA
TorstenH. 7-Nov-12 1:22am    
Please add your code to the question by using the "improve Question" function.

Please, at least make an effort to do your own homework.
 
Share this answer
 
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.
 
Share this answer
 
v2
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" );
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900