Multi-layer if loop __ game

Source: Internet
Author: User
Import Java.util.Scanner;
public class date//The little game of a blind date
{
public static void Main (string[] args)
{

Scanner sc = new Scanner (system.in);
System.out.println ("Please enter your gender: such as male/female");
String sex = Sc.next ();

if (Sex.equals ("female")) {
System.out.println ("Please enter your Age:");
int age = Sc.nextint ();
if (age<30) {
System.out.println ("Please enter your height: such as 17.3");
Double height = sc.nextdouble ();
if (height>=16.0) {
System.out.println ("About it.") ");
}else{
System.out.println ("I hope you find the next one soon.") ");
}
}else{
System.out.println ("Sorry.") Customer is not in service area ");
}

}else{
System.out.println ("Sorry, the identity does not match.") ");
}
}

}

Personally think this is a look very clear if nested loops, when I finish this topic, I feel the idea of doing other loops clearer, from the outside, so upload it, albeit very simply,

I do this: this cycle is not written from the top down, but to write an if loop and then write the loop in it, according to the conditions, write it quickly

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.