Explore a diverse range of topics and get expert answers on IDNLearn.com. Get accurate and timely answers to your queries from our extensive network of experienced professionals.

Write Java code to display a dialog box that asks the user to enter his or her desired annual income. Store the input in a double variable and display it in a message dialog box. public class AnnualIncome { public static void main(String[] args) { // Write your Java code here } }

Sagot :

Answer:

Follows are the code to the given question:

import java.util.*;//import package for user-input

public class AnnualIncome // defining a class AnnualIncome

{

public static void main(String[] as)//defining main method

{

double income;//defining double variable

Scanner obx=new Scanner(System.in);//creating Scanner class for user-input

System.out.print("Please enter your desired annual income: ");//print message

income=obx.nextDouble();//input double value

System.out.println("Your income "+income);//print value

}

}

Output:

Please enter your desired annual income: 98659.89

Your income 98659.89

Explanation:

In this code, a class "AnnualIncome" is declared, and inside the main method, the double variable "income" is defined, that uses the scanner class concept for input the value from the user-end, and in the next step, it uses the print method for asked user to enter  value and it uses the print method, that prints income value with the given message.

We are delighted to have you as part of our community. Keep asking, answering, and sharing your insights. Together, we can create a valuable knowledge resource. IDNLearn.com provides the answers you need. Thank you for visiting, and see you next time for more valuable insights.