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 Programing Display any welcome message at the top of the output screen Create following variables:...
Java Programing Display any welcome message at the top of the output screen Create following variables: Price for a cup of coffee (make it adjustable within the program) Number of cups (response from User) Tax Rate in San Diego is 8%. Define 8% as a CONSTANT variable that never changes Payment Method (Cash, Credit Card, Store Credit, Gold) Ask the customer for their first name, and store it as a String object. Ask the customer (by name) how many cups...
Display a simple message "Welcome" on your demo webpage. When the user hovers over the message,...
Display a simple message "Welcome" on your demo webpage. When the user hovers over the message, a popup should be displayed with a message "Welcome to our new WebPage!!!".
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...
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...
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,...
Write a java program that will first display the following menu: Choose one of the following...
Write a java program that will first display the following menu: Choose one of the following 1- To add 2 double integers 2- To add 2 integer numbers 3- To add 3 double numbers 4- To add 3 integer numbers After reading user’s choice, use a switch case statement to call the corresponding method Void add 1 (double n1, double n2) Void add2() Double add3 (double n1, double n2, double n3) Double add4 ()
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...
Specifications: Write a Java program called LifeRaft.java that will do all of the following: Display a...
Specifications: Write a Java program called LifeRaft.java that will do all of the following: Display a title Ask the user to enter the following values: The type of plane(Boeing 747 or Airbus A300) The number of passengers on board the Plane The number of crew aboard the plane The maximum number of people that can be carried by one liferaft assuming all the liferafts on the plane are the same size The actual number of liferafts that are available on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT