Some summaries and self-reminders of basic Java exams

Source: Internet
Author: User

A simple learner-state converter

Import Java.util.scanner;public class Student {public static void main (string[] args) {Student.run ();} public static void Run () {System.out.println ("************** Welcome to Learner State Translator ***************"); Scanner sc = new Scanner (system.in), while (true) {System.out.println ("Enter the first English letter of the learner's status:");//Gets the status of the learner entered by the user the control Word, String str = Sc.next (); switch (str) {case ' E ': Case "E": System.out.println ("excellent"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user, string num = Sc.next ();//Determine if the user is continuing to enter? Switch (num) {case "Y": Continue;case "n": System.exit (0);d efault:System.out.println ("Input error, please reenter");} Case "G": Case "G": System.out.println ("good"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user string num1 = Sc.next ();//Determine if the user is continuing to enter? Switch (NUM1) {case "Y": Continue;case "n": System.exit (0);d efault:System.out.println ("Input error, please reenter");} Case ' s ': Case "S": System.out.println ("medium"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user string num2 = Sc.next ();//Determine if the user is continuing to enter? Switch (num2) {case "Y": Continue;case "n": System.exit (0);d Efault:System.out.prinTLN ("Input error, please re-enter");} Case ' F ': Case "F": System.out.println ("unqualified"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user string num3 = Sc.next ();//Determine if the user is continuing to enter? Switch (num3) {case "Y": Continue;case "n": System.exit (0);d efault:System.out.println ("Input error, please reenter");} Case "H": Case "H": System.out.println ("input error, unable to convert"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user string num4 = Sc.next ();//Determine if the user is continuing to enter? Switch (NUM4) {case "Y": Continue;case "n": System.exit (0);d efault:System.out.println ("Input error, please reenter");} DEFAULHT:SYSTEM.OUT.PRINTLN ("input error"); System.out.println ("Do you want to continue?" (y/n);//Gets the word entered by the user string num5 = Sc.next ();//Determine if the user is continuing to enter? Switch (NUM5) {case "Y": Continue;case "n": System.exit (0);d efault:System.out.println ("Input error, reenter");}}}}

This is the stupidest thing I wrote when I was in the exam, not recommended. Do you want to continue? Can be written as a method below, and then call the above directly below the SANFA on it.

Note: The input is all characters, so double quotation marks are added.

I just forgot to add double quotation marks when I was in the exam, only the most stupid way to write, so my blog sent to remind me of the time

Some summaries and self-reminders of basic Java exams

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.