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 7:55am
Edited 7-Nov-12 4: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 2

Please, at least make an effort to do your own homework.
  Permalink  
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  

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 8,438
1 OriginalGriff 6,491
2 Peter Leow 3,567
3 Zoltán Zörgő 3,326
4 Richard MacCutchan 2,397


Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2015
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