Results 1 to 2 of 2
- 02-29-2012, 01:20 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 13
- Rep Power
- 0
Help with Int and JOption Input dialog
Im doing calculations for world population and I already have a formula and everything is working, but my question is when it asks to put "Enter years to see World Population Growth" what do i need to put for my int c when int c is unknown???? please help....
Java Code:import java.util.Scanner; import javax.swing.JOptionPane; public class Population { public static void main(String[] args) { Scanner input = new Scanner( System.in ); int a = 7; double b = 1.0114; int c; double answer = c * a + b; JOptionPane.showMessageDialog(null, "Welcome to World population profile!\nCurrent world population of year 2012 is 7 billion\nand current world population growth rate of year 2012 is 1.14%"); String years = JOptionPane.showInputDialog( "Enter years to see World Population Growth "); String message = String.format( "World Population Growth in %s years is " , years ); JOptionPane.showMessageDialog(null, message + answer); } }
-
Re: Help with Int and JOption Input dialog
You've got things a little backwards in that you're trying to create your equation before you know the data to put in, and that won't work. Instead you will want to get your input first, and then use the inputted value in your equation.
Similar Threads
-
Problem with Looping input dialog
By kiraichi in forum New To JavaReplies: 3Last Post: 02-11-2012, 09:14 PM -
How to create custom Input Dialog
By Bab in forum SWT / JFaceReplies: 2Last Post: 08-02-2009, 12:21 PM -
Creating a Number Input Dialog in SWT
By Java Tip in forum SWTReplies: 0Last Post: 07-02-2008, 07:53 PM -
Input Verification Dialog Demo
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:43 PM -
JOptionPane - input dialog
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 09:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks