Java Applet exercises

Source: Internet
Author: User

/*
* 1. byte byte_n1;
* Short short_n1 = 10;
* Short short_n2;
* Int int_n1 = 3000000;
* Int int_n2, int_n3;
* Long long_n1 = 400;
* Long long_n2, long_n3;
* Byte_n1 = short_n1;
* Byte_n1 = (byte) short_n1;
* Short_n2 = (short) int_n1;
* Int_n2 = int_n1 * short_n1;
* Int_n3 = long_n1 * short_n1;
* Long_n2 = int_n1 * 2000;
* Long_n3 = int_n1 * 2000L;
* 2. Computer Verification
* Public class Example {
* Public static void main (String [] args ){
* Int a = 20, B = 50, c = 100, d;
* A % = 9;
* B/= 7;
* C % = B;
* D = a + B + c;
* System. out. println ("a =" + );
* System. out. println ("B =" + B );
* System. out. println ("c =" + c );
* System. out. println ("d =" + d );
*}
*}
* 3. Write an application that reads three non-zero data input by the user and determines whether the three data output can constitute a triangle.
* 4. Use the switch statement to compile a program that completes the four arithmetic operations of two integers.
* 5. Write an application and calculate the value of 1*1-2*2 + 3*3-4*4 +...-100*100.
* 6. Write an application, and calculate 1! + 2! + ...... + 20! And display, output 1 at the same time! , 2! , 3 !... .
**/
Package ch3;
 
/* Public class Example {
 
Public static void main (String [] args ){
Int a = 20, B = 50, c = 100, d;
A % = 9;
B/= 7;
C % = B;
D = a + B + c;
System. out. println ("a =" + );
System. out. println ("B =" + B );
System. out. println ("c =" + c );
System. out. println ("d =" + d );
}
}*/
/* Import java. util. collections;
* Public class PanDuanSanJiao {
Public static void main (String [] args ){
S = new partition (System. in );
System. out. println ("Enter three integers ");
Int a = s. nextInt ();
Int B = s. nextInt ();
Int c = s. nextInt ();
If (a <0 | B <0 | c <0 ){
System. out. println ("enter a positive number ");
} Else if (a + B> c & a + c> B & B + c> ){
System. out. println ("triangles can be formed ");
}
}
}*/
/* Public class SiZeYunSuan {
Public static void main (String [] args ){
Int a = 10;
Int B = 20;
Char operator = '+ ';
Switch (operator ){
Case '+ ':
System. out. println (a + "+" + B + "=" + (a + B ));
Break;
Case '-':
System. out. println (a + "-" + B + "=" + (a-B ));
Break;
Case '*':
System. out. println (a + "*" + B + "=" + (a * B ));
Break;
Case '/':
System. out. println (a + "/" + B + "=" + (a/B ));
Break;
Default:
System. out. println ("-1 ");
}
}
}*/
/* Public class QiuZhi {
Public static void main (String [] args ){
Int sum = 0;
For (int I = 1; I <= 100; I ++ ){
If (I % 2 = 1 ){
Sum + = I * I;
} Else {
Sum-= I * I;
}
}
System. out. println ("and" + sum );
}
}*/
/* Public class JC {
Public static void main (String [] args ){
Long sum = 0;
Long result = 1;
For (int I = 1; I <= 20; I ++ ){
Result * = I;
System. out. println (the factorial of I + "is:" + result );
Sum + = result;
}
System. out. println ("the factorial sum between 1 and 20 is:" + sum );
}
}*/

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.