Write a program that can receive two numbers and determine whether the two numbers are greater than, less than, or equal ?, Write and receive

Source: Internet
Author: User

Write a program that can receive two numbers and determine whether the two numbers are greater than, less than, or equal ?, Write and receive

// Author: janushu // Date: 2017/9/20 // function to determine the size of two numbers import java. io. *; public class CompareToNumDemo {public static void main (String [] args) {try {// enter a number of InputStreamReader isr = new InputStreamReader (System. in); // The cache reads a number of BufferedReader br = new BufferedReader (isr); System. out. println ("Enter the first number"); // read a row of data from the console String snum1 = br. readLine (); System. out. println ("enter the second number"); String snum2 = br. readLine (); float fnum1 = Float. parseFloat (snum1); float fnum2 = Float. parseFloat (snum2); if (fnum1> fnum2) {System. out. println (fnum1 + "greater than" + fnum2);} if (fnum1 = fnum2) {System. out. println (fnum1 + "equals" + fnum2);} if (fnum1> fnum2) {System. out. println (fnum1 + "less than" + fnum2) ;}} catch (Exception e) {System. out. println ("unable to judge ");}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.