Question

In: Computer Science

Give a Java Statement that will display a dialogue window with the following message. “Java looks...

  1. Give a Java Statement that will display a dialogue window with the following message.

“Java looks good”                                                                                                        

2. Write a code in java – create a method “s”. Insert 10 floating-point numbers in it. Using iterator find the sum of those numbers.       

3. Write a Java program to read integers (for ex: 2017). Display it one digit per line in reverse order.

7

1

0

2

  1. Write a Program that inputs a double value. If the double value is greater than 150.45 or between 60.30 and 70.25 (inclusive), then output YES. Otherwise output NO.

  

Solutions

Expert Solution

1).

import javax.swing.JFrame;
import javax.swing.JOptionPane;


public class DialogueBox {
   JFrame f;
   DialogueBox(){
   f=new JFrame();
   JOptionPane.showMessageDialog(f,"Java looks good!");
   }
   public static void main(String[] args) {
   new DialogueBox();
   }
}

output:

====

2).

Code:

====

import java.util.ArrayList;
import java.util.Iterator;

public class FloatingIterator {
   public static void main(String[] args) {
       ArrayList<Double> al = new ArrayList<Double>();
       al.add(1.12);
       al.add(2.12);
       al.add(3.12);
       al.add(4.12);
       al.add(5.12);
       al.add(6.12);
       al.add(7.12);
       al.add(8.12);
       al.add(9.12);
       al.add(10.12);
       s(al);
   }
  
   public static void s(ArrayList<Double> al) {
       Iterator<Double> it = al.iterator();
       while(it.hasNext()) {
           System.out.println(it.next());
       }
   }
}

output:

=====

3).

import java.util.Scanner;

public class ReverseDigits {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter a number: ");
       int input = sc.nextInt();
      
       while(input%10!=input) {
           System.out.println(input%10);
           input = input/10;
       }
       System.out.println(input);
      
       sc.close();
   }
}

output:

=====

4).

import java.util.Scanner;

public class FloatBetween {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter a number: ");
       double input = sc.nextDouble();
       if(input>150.45 || (input>=60.30 && input<=70.25)) {
           System.out.println("YES");
       }
       else {
           System.out.println("NO");
       }
       sc.close();
   }
}

output:

====


Related Solutions

Java code for a binary tree that does the following:  Display a menu to the...
Java code for a binary tree that does the following:  Display a menu to the user and request for the desired option.  Based on the user’s input, request for additional information as follows: o If the user wants to add a node, request for the name (or ID) of the new node to be added as well as the name of the desired parent of that node.  If the parent node already has two children, the new...
Java code for a binary tree that does the following:  Display a menu to the...
Java code for a binary tree that does the following:  Display a menu to the user and request for the desired option.  Based on the user’s input, request for additional information as follows: o If the user wants to add a node, request for the name (or ID) of the new node to be added as well as the name of the desired parent of that node.  If the parent node already has two children, the new...
Complete the following in syntactically correct Python code. 1. The program should display a message indicating...
Complete the following in syntactically correct Python code. 1. The program should display a message indicating whether the person is an infant, a child, a teenager, or an adult. Following are the guidelines: a. If the person is older than 1 year old or less, he or she is an infant. b. If the person is older than 1 year, but younger than 13, he or she is a child c. If the person is at least 13 years old,...
Use the following Window Breeze Company income statement to answer the question. Window Breeze Company is...
Use the following Window Breeze Company income statement to answer the question. Window Breeze Company is a small manufacturer of window air conditioners and reported the following: Window Breeze Company Full Costing Income Statement For the Year Ending December 31, 2011 Sales ($150 per unit) $120,000 Less cost of goods sold 35,000 Gross margin 85,000 Less selling and administrative expenses: Selling expense $15,000 Administrative expense 15,000 30,000 Net income $55,000 Annual FMOH was $25,000 and 1,000 units were produced. All...
Ms. Smart looks out of her office window on the 38th floor of the Central Bank...
Ms. Smart looks out of her office window on the 38th floor of the Central Bank of Fairytale. She just finished flipping through the Fairytale’s Economic Outlook report put together by the Policy Unit division of the Central Bank. In the report, consumer spending has decreased by 2% from the previous fiscal year, and the country’s real GDP dwindled by 3% from the previous year. The GDP of Fairytale was 3.0 billion Fairytale Dollars (F$) and F$2.9 billion in 2017...
Create a JavaFX program in java that does the following items: Display a drawing area of...
Create a JavaFX program in java that does the following items: Display a drawing area of dimension 500 x 400, with a black background. Provides a radio button group to allow the user to select one of the following three colors: red, green, and blue. Upon startup, the red radio button should be selected. Each time the user clicks in the drawing area, a circle of size 10 of the color selected by the radio button group in item 2...
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT