/* (start of program header comment) * Copyright and Version Statement of program (c) 2011, student of Computer College of Yantai University * All rights reserved. * File Name: * Author: Shangpeng * Date of Completion: September 15, 2012 * Version number: 001 * Description of task and solution * Input description
: * Problem Description: Enter a number and use the IF statement to determine the matching number. If the input is: 1> Print: The number you entered is 1 2>. Print: The number you entered is 2 3>.
Print: You entered the digital 3 other digital printing: entered the nonstandard number note: The use of if-else and switch two ways to achieve respectively. * Program Output: * Program Header comment End/public class Test3 {/** * @param args/public static void main (string[] args) {Syste
M.out.println ("Please enter a number:");
String str1= console.readline ();
int x = Integer.parseint (STR1);
if (x = = 1) System.out.println ("The number you enter is 1");
if (x ==2) System.out.println ("The number you enter is 2");
if (x = = 3) System.out.println ("The number you enter is 3");
if (x!=1 &&x!= 2&&x!=3) System.out.println ("You have entered a number that does not conform to the specification"); }
}
public class Test3 {
/**
* @param args
*
/public static void main (string[] args) {
System.out.println ("Please enter a number:");
String str1= console.readline ();
int x = Integer.parseint (str1);
Switch (x)
{case
1:
System.out.println ("The number you entered is 1:");
break;
Case 2:
System.out.println ("The number you entered is 2:");
break;
Case 3:
System.out.println ("The number you entered is 3:");
break;
Default:
System.out.println ("The number you entered does not conform to spec:");}