Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java
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 6:55am
Edited 7-Nov-12 3:20am
v3
Comments
Sergey Alexandrovich Kryukov at 6-Nov-12 13:36pm
   
A formula? (sigh...)...
--SA
TorstenH. at 7-Nov-12 1:22am
   
Please add your code to the question by using the "improve Question" function.
Rate this: bad
good
Please Sign up or sign in to vote.

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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

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" );
    }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Please, at least make an effort to do your own homework.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 355
1 _Amy 235
2 Peter Leow 185
3 Andreas Gieriet 180
4 Dave Kreskowiak 155
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,462
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100